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
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/util/AsyncTaskExecutor.java
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskCallback.java // public interface TaskCallback<R, E extends Exception> { // // void onSuccess(R result); // // void onError(E error); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import android.os.Handler; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskCallback; import cat.ppicas.framework.task.TaskExecutor; import cat.ppicas.framework.task.TaskResult;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.util; /** * A {@link TaskExecutor} implementation that executes tasks on another thread. This class * will not execute various {@link Task} concurrently. Instead the tasks will be added to the * queue and execute one by one respecting the execution order. */ public class AsyncTaskExecutor implements TaskExecutor { private final Executor mExecutor = Executors.newSingleThreadExecutor(); private final Handler mHandler = new Handler(); private final List<WeakReference<?>> mRunningTasks = new ArrayList<>(); @Override public <R, E extends Exception> void execute(
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskCallback.java // public interface TaskCallback<R, E extends Exception> { // // void onSuccess(R result); // // void onError(E error); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: app/src/main/java/cat/ppicas/cleanarch/util/AsyncTaskExecutor.java import android.os.Handler; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskCallback; import cat.ppicas.framework.task.TaskExecutor; import cat.ppicas.framework.task.TaskResult; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.util; /** * A {@link TaskExecutor} implementation that executes tasks on another thread. This class * will not execute various {@link Task} concurrently. Instead the tasks will be added to the * queue and execute one by one respecting the execution order. */ public class AsyncTaskExecutor implements TaskExecutor { private final Executor mExecutor = Executors.newSingleThreadExecutor(); private final Handler mHandler = new Handler(); private final List<WeakReference<?>> mRunningTasks = new ArrayList<>(); @Override public <R, E extends Exception> void execute(
final Task<R, E> task, final TaskCallback<R, E> callback) {
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/util/AsyncTaskExecutor.java
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskCallback.java // public interface TaskCallback<R, E extends Exception> { // // void onSuccess(R result); // // void onError(E error); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import android.os.Handler; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskCallback; import cat.ppicas.framework.task.TaskExecutor; import cat.ppicas.framework.task.TaskResult;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.util; /** * A {@link TaskExecutor} implementation that executes tasks on another thread. This class * will not execute various {@link Task} concurrently. Instead the tasks will be added to the * queue and execute one by one respecting the execution order. */ public class AsyncTaskExecutor implements TaskExecutor { private final Executor mExecutor = Executors.newSingleThreadExecutor(); private final Handler mHandler = new Handler(); private final List<WeakReference<?>> mRunningTasks = new ArrayList<>(); @Override public <R, E extends Exception> void execute(
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskCallback.java // public interface TaskCallback<R, E extends Exception> { // // void onSuccess(R result); // // void onError(E error); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: app/src/main/java/cat/ppicas/cleanarch/util/AsyncTaskExecutor.java import android.os.Handler; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskCallback; import cat.ppicas.framework.task.TaskExecutor; import cat.ppicas.framework.task.TaskResult; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.util; /** * A {@link TaskExecutor} implementation that executes tasks on another thread. This class * will not execute various {@link Task} concurrently. Instead the tasks will be added to the * queue and execute one by one respecting the execution order. */ public class AsyncTaskExecutor implements TaskExecutor { private final Executor mExecutor = Executors.newSingleThreadExecutor(); private final Handler mHandler = new Handler(); private final List<WeakReference<?>> mRunningTasks = new ArrayList<>(); @Override public <R, E extends Exception> void execute(
final Task<R, E> task, final TaskCallback<R, E> callback) {
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/util/AsyncTaskExecutor.java
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskCallback.java // public interface TaskCallback<R, E extends Exception> { // // void onSuccess(R result); // // void onError(E error); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import android.os.Handler; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskCallback; import cat.ppicas.framework.task.TaskExecutor; import cat.ppicas.framework.task.TaskResult;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.util; /** * A {@link TaskExecutor} implementation that executes tasks on another thread. This class * will not execute various {@link Task} concurrently. Instead the tasks will be added to the * queue and execute one by one respecting the execution order. */ public class AsyncTaskExecutor implements TaskExecutor { private final Executor mExecutor = Executors.newSingleThreadExecutor(); private final Handler mHandler = new Handler(); private final List<WeakReference<?>> mRunningTasks = new ArrayList<>(); @Override public <R, E extends Exception> void execute( final Task<R, E> task, final TaskCallback<R, E> callback) { addRunningTask(task); mExecutor.execute(new Runnable() { @Override public void run() {
// Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskCallback.java // public interface TaskCallback<R, E extends Exception> { // // void onSuccess(R result); // // void onError(E error); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: app/src/main/java/cat/ppicas/cleanarch/util/AsyncTaskExecutor.java import android.os.Handler; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.Executor; import java.util.concurrent.Executors; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskCallback; import cat.ppicas.framework.task.TaskExecutor; import cat.ppicas.framework.task.TaskResult; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.util; /** * A {@link TaskExecutor} implementation that executes tasks on another thread. This class * will not execute various {@link Task} concurrently. Instead the tasks will be added to the * queue and execute one by one respecting the execution order. */ public class AsyncTaskExecutor implements TaskExecutor { private final Executor mExecutor = Executors.newSingleThreadExecutor(); private final Handler mHandler = new Handler(); private final List<WeakReference<?>> mRunningTasks = new ArrayList<>(); @Override public <R, E extends Exception> void execute( final Task<R, E> task, final TaskCallback<R, E> callback) { addRunningTask(task); mExecutor.execute(new Runnable() { @Override public void run() {
final TaskResult<R, E> result = task.execute();
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityCurrentWeatherFragment.java
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityCurrentWeatherPresenter.java // public class CityCurrentWeatherPresenter extends Presenter<CityCurrentWeatherVista> { // // private final TaskExecutor mTaskExecutor; // private final CurrentWeatherRepository mRepository; // private final String mCityId; // // private GetCurrentWeatherTask mGetCurrentWeatherTask; // private CurrentWeather mLastCurrentWeather; // // public CityCurrentWeatherPresenter(TaskExecutor taskExecutor, // CurrentWeatherRepository repository, String cityId) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // } // // @Override // public void onStart(CityCurrentWeatherVista vista) { // if (mLastCurrentWeather != null) { // updateVista(vista, mLastCurrentWeather); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetCurrentWeatherTask)) { // mGetCurrentWeatherTask = new GetCurrentWeatherTask(mRepository, mCityId); // mTaskExecutor.execute(mGetCurrentWeatherTask, new GetCurrentWeatherTaskCallback()); // } // } // } // // private void updateVista(CityCurrentWeatherVista vista, CurrentWeather cw) { // vista.setCurrentTemp(NumberFormat.formatTemperature(cw.getCurrentTemp())); // vista.setHumidity(NumberFormat.formatHumidity(cw.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(cw.getWindSpeed())); // } // // private class GetCurrentWeatherTaskCallback extends DisplayErrorTaskCallback<CurrentWeather> { // public GetCurrentWeatherTaskCallback() { // super(CityCurrentWeatherPresenter.this); // } // // @Override // public void onSuccess(CurrentWeather cw) { // mLastCurrentWeather = cw; // CityCurrentWeatherVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // updateVista(vista, cw); // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityCurrentWeatherVista.java // public interface CityCurrentWeatherVista extends TaskResultVista { // // void setCurrentTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // }
import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityCurrentWeatherVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityCurrentWeatherPresenter; import cat.ppicas.framework.ui.PresenterFactory;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.ui.fragment; public class CityCurrentWeatherFragment extends Fragment implements CityCurrentWeatherVista, PresenterFactory<CityCurrentWeatherPresenter> { private static final String ARG_CITY_ID = "cityId"; private String mCityId; private CityCurrentWeatherPresenter mPresenter; private TextView mCurrent; private TextView mHumidity; private TextView mWindSpeed; private View mLoading; public static CityCurrentWeatherFragment newInstance(String cityId) { Bundle args = new Bundle(); args.putString(ARG_CITY_ID, cityId); CityCurrentWeatherFragment fragment = new CityCurrentWeatherFragment(); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args == null || !args.containsKey(ARG_CITY_ID)) { throw new IllegalArgumentException("Invalid Fragment arguments"); } mCityId = args.getString(ARG_CITY_ID);
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityCurrentWeatherPresenter.java // public class CityCurrentWeatherPresenter extends Presenter<CityCurrentWeatherVista> { // // private final TaskExecutor mTaskExecutor; // private final CurrentWeatherRepository mRepository; // private final String mCityId; // // private GetCurrentWeatherTask mGetCurrentWeatherTask; // private CurrentWeather mLastCurrentWeather; // // public CityCurrentWeatherPresenter(TaskExecutor taskExecutor, // CurrentWeatherRepository repository, String cityId) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // } // // @Override // public void onStart(CityCurrentWeatherVista vista) { // if (mLastCurrentWeather != null) { // updateVista(vista, mLastCurrentWeather); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetCurrentWeatherTask)) { // mGetCurrentWeatherTask = new GetCurrentWeatherTask(mRepository, mCityId); // mTaskExecutor.execute(mGetCurrentWeatherTask, new GetCurrentWeatherTaskCallback()); // } // } // } // // private void updateVista(CityCurrentWeatherVista vista, CurrentWeather cw) { // vista.setCurrentTemp(NumberFormat.formatTemperature(cw.getCurrentTemp())); // vista.setHumidity(NumberFormat.formatHumidity(cw.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(cw.getWindSpeed())); // } // // private class GetCurrentWeatherTaskCallback extends DisplayErrorTaskCallback<CurrentWeather> { // public GetCurrentWeatherTaskCallback() { // super(CityCurrentWeatherPresenter.this); // } // // @Override // public void onSuccess(CurrentWeather cw) { // mLastCurrentWeather = cw; // CityCurrentWeatherVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // updateVista(vista, cw); // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityCurrentWeatherVista.java // public interface CityCurrentWeatherVista extends TaskResultVista { // // void setCurrentTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityCurrentWeatherFragment.java import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityCurrentWeatherVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityCurrentWeatherPresenter; import cat.ppicas.framework.ui.PresenterFactory; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.ui.fragment; public class CityCurrentWeatherFragment extends Fragment implements CityCurrentWeatherVista, PresenterFactory<CityCurrentWeatherPresenter> { private static final String ARG_CITY_ID = "cityId"; private String mCityId; private CityCurrentWeatherPresenter mPresenter; private TextView mCurrent; private TextView mHumidity; private TextView mWindSpeed; private View mLoading; public static CityCurrentWeatherFragment newInstance(String cityId) { Bundle args = new Bundle(); args.putString(ARG_CITY_ID, cityId); CityCurrentWeatherFragment fragment = new CityCurrentWeatherFragment(); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); if (args == null || !args.containsKey(ARG_CITY_ID)) { throw new IllegalArgumentException("Invalid Fragment arguments"); } mCityId = args.getString(ARG_CITY_ID);
mPresenter = ((PresenterHolder) getActivity()).getOrCreatePresenter(this);
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityCurrentWeatherFragment.java
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityCurrentWeatherPresenter.java // public class CityCurrentWeatherPresenter extends Presenter<CityCurrentWeatherVista> { // // private final TaskExecutor mTaskExecutor; // private final CurrentWeatherRepository mRepository; // private final String mCityId; // // private GetCurrentWeatherTask mGetCurrentWeatherTask; // private CurrentWeather mLastCurrentWeather; // // public CityCurrentWeatherPresenter(TaskExecutor taskExecutor, // CurrentWeatherRepository repository, String cityId) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // } // // @Override // public void onStart(CityCurrentWeatherVista vista) { // if (mLastCurrentWeather != null) { // updateVista(vista, mLastCurrentWeather); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetCurrentWeatherTask)) { // mGetCurrentWeatherTask = new GetCurrentWeatherTask(mRepository, mCityId); // mTaskExecutor.execute(mGetCurrentWeatherTask, new GetCurrentWeatherTaskCallback()); // } // } // } // // private void updateVista(CityCurrentWeatherVista vista, CurrentWeather cw) { // vista.setCurrentTemp(NumberFormat.formatTemperature(cw.getCurrentTemp())); // vista.setHumidity(NumberFormat.formatHumidity(cw.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(cw.getWindSpeed())); // } // // private class GetCurrentWeatherTaskCallback extends DisplayErrorTaskCallback<CurrentWeather> { // public GetCurrentWeatherTaskCallback() { // super(CityCurrentWeatherPresenter.this); // } // // @Override // public void onSuccess(CurrentWeather cw) { // mLastCurrentWeather = cw; // CityCurrentWeatherVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // updateVista(vista, cw); // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityCurrentWeatherVista.java // public interface CityCurrentWeatherVista extends TaskResultVista { // // void setCurrentTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // }
import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityCurrentWeatherVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityCurrentWeatherPresenter; import cat.ppicas.framework.ui.PresenterFactory;
mPresenter.stop(); } @Override public void setCurrentTemp(String temp) { mCurrent.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityCurrentWeatherPresenter createPresenter() {
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityCurrentWeatherPresenter.java // public class CityCurrentWeatherPresenter extends Presenter<CityCurrentWeatherVista> { // // private final TaskExecutor mTaskExecutor; // private final CurrentWeatherRepository mRepository; // private final String mCityId; // // private GetCurrentWeatherTask mGetCurrentWeatherTask; // private CurrentWeather mLastCurrentWeather; // // public CityCurrentWeatherPresenter(TaskExecutor taskExecutor, // CurrentWeatherRepository repository, String cityId) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // } // // @Override // public void onStart(CityCurrentWeatherVista vista) { // if (mLastCurrentWeather != null) { // updateVista(vista, mLastCurrentWeather); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetCurrentWeatherTask)) { // mGetCurrentWeatherTask = new GetCurrentWeatherTask(mRepository, mCityId); // mTaskExecutor.execute(mGetCurrentWeatherTask, new GetCurrentWeatherTaskCallback()); // } // } // } // // private void updateVista(CityCurrentWeatherVista vista, CurrentWeather cw) { // vista.setCurrentTemp(NumberFormat.formatTemperature(cw.getCurrentTemp())); // vista.setHumidity(NumberFormat.formatHumidity(cw.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(cw.getWindSpeed())); // } // // private class GetCurrentWeatherTaskCallback extends DisplayErrorTaskCallback<CurrentWeather> { // public GetCurrentWeatherTaskCallback() { // super(CityCurrentWeatherPresenter.this); // } // // @Override // public void onSuccess(CurrentWeather cw) { // mLastCurrentWeather = cw; // CityCurrentWeatherVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // updateVista(vista, cw); // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityCurrentWeatherVista.java // public interface CityCurrentWeatherVista extends TaskResultVista { // // void setCurrentTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityCurrentWeatherFragment.java import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityCurrentWeatherVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityCurrentWeatherPresenter; import cat.ppicas.framework.ui.PresenterFactory; mPresenter.stop(); } @Override public void setCurrentTemp(String temp) { mCurrent.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityCurrentWeatherPresenter createPresenter() {
ServiceContainer sc = ServiceContainers.getFromApp(getActivity());
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityCurrentWeatherFragment.java
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityCurrentWeatherPresenter.java // public class CityCurrentWeatherPresenter extends Presenter<CityCurrentWeatherVista> { // // private final TaskExecutor mTaskExecutor; // private final CurrentWeatherRepository mRepository; // private final String mCityId; // // private GetCurrentWeatherTask mGetCurrentWeatherTask; // private CurrentWeather mLastCurrentWeather; // // public CityCurrentWeatherPresenter(TaskExecutor taskExecutor, // CurrentWeatherRepository repository, String cityId) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // } // // @Override // public void onStart(CityCurrentWeatherVista vista) { // if (mLastCurrentWeather != null) { // updateVista(vista, mLastCurrentWeather); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetCurrentWeatherTask)) { // mGetCurrentWeatherTask = new GetCurrentWeatherTask(mRepository, mCityId); // mTaskExecutor.execute(mGetCurrentWeatherTask, new GetCurrentWeatherTaskCallback()); // } // } // } // // private void updateVista(CityCurrentWeatherVista vista, CurrentWeather cw) { // vista.setCurrentTemp(NumberFormat.formatTemperature(cw.getCurrentTemp())); // vista.setHumidity(NumberFormat.formatHumidity(cw.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(cw.getWindSpeed())); // } // // private class GetCurrentWeatherTaskCallback extends DisplayErrorTaskCallback<CurrentWeather> { // public GetCurrentWeatherTaskCallback() { // super(CityCurrentWeatherPresenter.this); // } // // @Override // public void onSuccess(CurrentWeather cw) { // mLastCurrentWeather = cw; // CityCurrentWeatherVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // updateVista(vista, cw); // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityCurrentWeatherVista.java // public interface CityCurrentWeatherVista extends TaskResultVista { // // void setCurrentTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // }
import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityCurrentWeatherVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityCurrentWeatherPresenter; import cat.ppicas.framework.ui.PresenterFactory;
mPresenter.stop(); } @Override public void setCurrentTemp(String temp) { mCurrent.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityCurrentWeatherPresenter createPresenter() {
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityCurrentWeatherPresenter.java // public class CityCurrentWeatherPresenter extends Presenter<CityCurrentWeatherVista> { // // private final TaskExecutor mTaskExecutor; // private final CurrentWeatherRepository mRepository; // private final String mCityId; // // private GetCurrentWeatherTask mGetCurrentWeatherTask; // private CurrentWeather mLastCurrentWeather; // // public CityCurrentWeatherPresenter(TaskExecutor taskExecutor, // CurrentWeatherRepository repository, String cityId) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // } // // @Override // public void onStart(CityCurrentWeatherVista vista) { // if (mLastCurrentWeather != null) { // updateVista(vista, mLastCurrentWeather); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetCurrentWeatherTask)) { // mGetCurrentWeatherTask = new GetCurrentWeatherTask(mRepository, mCityId); // mTaskExecutor.execute(mGetCurrentWeatherTask, new GetCurrentWeatherTaskCallback()); // } // } // } // // private void updateVista(CityCurrentWeatherVista vista, CurrentWeather cw) { // vista.setCurrentTemp(NumberFormat.formatTemperature(cw.getCurrentTemp())); // vista.setHumidity(NumberFormat.formatHumidity(cw.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(cw.getWindSpeed())); // } // // private class GetCurrentWeatherTaskCallback extends DisplayErrorTaskCallback<CurrentWeather> { // public GetCurrentWeatherTaskCallback() { // super(CityCurrentWeatherPresenter.this); // } // // @Override // public void onSuccess(CurrentWeather cw) { // mLastCurrentWeather = cw; // CityCurrentWeatherVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // updateVista(vista, cw); // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityCurrentWeatherVista.java // public interface CityCurrentWeatherVista extends TaskResultVista { // // void setCurrentTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityCurrentWeatherFragment.java import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityCurrentWeatherVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityCurrentWeatherPresenter; import cat.ppicas.framework.ui.PresenterFactory; mPresenter.stop(); } @Override public void setCurrentTemp(String temp) { mCurrent.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityCurrentWeatherPresenter createPresenter() {
ServiceContainer sc = ServiceContainers.getFromApp(getActivity());
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDailyForecastFragment.java
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDailyForecastPresenter.java // public class CityDailyForecastPresenter extends Presenter<CityDailyForecastVista> { // // private final TaskExecutor mTaskExecutor; // private final DailyForecastRepository mRepository; // private final String mCityId; // private final int mDaysFromToday; // // private GetDailyForecastsTask mGetDailyForecastsTask; // private DailyForecast mLastDailyForecast; // // public CityDailyForecastPresenter(TaskExecutor taskExecutor, DailyForecastRepository repository, // String cityId, int daysFromToday) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // mDaysFromToday = daysFromToday; // } // // @Override // public void onStart(CityDailyForecastVista vista) { // if (mLastDailyForecast != null) { // updateVista(vista, mLastDailyForecast); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetDailyForecastsTask)) { // mGetDailyForecastsTask = new GetDailyForecastsTask(mRepository, mCityId); // mTaskExecutor.execute(mGetDailyForecastsTask, new GetDailyForecastTaskCallback()); // } // } // } // // private void updateVista(CityDailyForecastVista vista, DailyForecast df) { // vista.setForecastDescription(capitalizeFirstLetter( // df.getDescription())); // vista.setDayTemp(NumberFormat.formatTemperature(df.getDayTemp())); // vista.setMinTemp(NumberFormat.formatTemperature(df.getMinTemp())); // vista.setMaxTemp(NumberFormat.formatTemperature(df.getMaxTemp())); // vista.setHumidity(NumberFormat.formatHumidity(df.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(df.getWindSpeed())); // } // // private String capitalizeFirstLetter(String text) { // return text.substring(0, 1).toUpperCase() + text.substring(1); // } // // private class GetDailyForecastTaskCallback extends DisplayErrorTaskCallback<List<DailyForecast>> { // public GetDailyForecastTaskCallback() { // super(CityDailyForecastPresenter.this); // } // // @Override // public void onSuccess(List<DailyForecast> list) { // DailyForecast dailyForecast = null; // if (list.size() >= mDaysFromToday + 1) { // dailyForecast = list.get(mDaysFromToday); // } // // mLastDailyForecast = dailyForecast; // // CityDailyForecastVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // if (dailyForecast != null) { // updateVista(vista, dailyForecast); // } else { // vista.displayError(R.string.error__connection); // } // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDailyForecastVista.java // public interface CityDailyForecastVista extends TaskResultVista { // // void setForecastDescription(String description); // // void setDayTemp(String temp); // // void setMinTemp(String temp); // // void setMaxTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // }
import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityDailyForecastVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityDailyForecastPresenter; import cat.ppicas.framework.ui.PresenterFactory;
mMinTemp.setText(temp); } @Override public void setMaxTemp(String temp) { mMaxTemp.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityDailyForecastPresenter createPresenter() {
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDailyForecastPresenter.java // public class CityDailyForecastPresenter extends Presenter<CityDailyForecastVista> { // // private final TaskExecutor mTaskExecutor; // private final DailyForecastRepository mRepository; // private final String mCityId; // private final int mDaysFromToday; // // private GetDailyForecastsTask mGetDailyForecastsTask; // private DailyForecast mLastDailyForecast; // // public CityDailyForecastPresenter(TaskExecutor taskExecutor, DailyForecastRepository repository, // String cityId, int daysFromToday) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // mDaysFromToday = daysFromToday; // } // // @Override // public void onStart(CityDailyForecastVista vista) { // if (mLastDailyForecast != null) { // updateVista(vista, mLastDailyForecast); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetDailyForecastsTask)) { // mGetDailyForecastsTask = new GetDailyForecastsTask(mRepository, mCityId); // mTaskExecutor.execute(mGetDailyForecastsTask, new GetDailyForecastTaskCallback()); // } // } // } // // private void updateVista(CityDailyForecastVista vista, DailyForecast df) { // vista.setForecastDescription(capitalizeFirstLetter( // df.getDescription())); // vista.setDayTemp(NumberFormat.formatTemperature(df.getDayTemp())); // vista.setMinTemp(NumberFormat.formatTemperature(df.getMinTemp())); // vista.setMaxTemp(NumberFormat.formatTemperature(df.getMaxTemp())); // vista.setHumidity(NumberFormat.formatHumidity(df.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(df.getWindSpeed())); // } // // private String capitalizeFirstLetter(String text) { // return text.substring(0, 1).toUpperCase() + text.substring(1); // } // // private class GetDailyForecastTaskCallback extends DisplayErrorTaskCallback<List<DailyForecast>> { // public GetDailyForecastTaskCallback() { // super(CityDailyForecastPresenter.this); // } // // @Override // public void onSuccess(List<DailyForecast> list) { // DailyForecast dailyForecast = null; // if (list.size() >= mDaysFromToday + 1) { // dailyForecast = list.get(mDaysFromToday); // } // // mLastDailyForecast = dailyForecast; // // CityDailyForecastVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // if (dailyForecast != null) { // updateVista(vista, dailyForecast); // } else { // vista.displayError(R.string.error__connection); // } // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDailyForecastVista.java // public interface CityDailyForecastVista extends TaskResultVista { // // void setForecastDescription(String description); // // void setDayTemp(String temp); // // void setMinTemp(String temp); // // void setMaxTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDailyForecastFragment.java import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityDailyForecastVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityDailyForecastPresenter; import cat.ppicas.framework.ui.PresenterFactory; mMinTemp.setText(temp); } @Override public void setMaxTemp(String temp) { mMaxTemp.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityDailyForecastPresenter createPresenter() {
ServiceContainer sc = ServiceContainers.getFromApp(getActivity());
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDailyForecastFragment.java
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDailyForecastPresenter.java // public class CityDailyForecastPresenter extends Presenter<CityDailyForecastVista> { // // private final TaskExecutor mTaskExecutor; // private final DailyForecastRepository mRepository; // private final String mCityId; // private final int mDaysFromToday; // // private GetDailyForecastsTask mGetDailyForecastsTask; // private DailyForecast mLastDailyForecast; // // public CityDailyForecastPresenter(TaskExecutor taskExecutor, DailyForecastRepository repository, // String cityId, int daysFromToday) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // mDaysFromToday = daysFromToday; // } // // @Override // public void onStart(CityDailyForecastVista vista) { // if (mLastDailyForecast != null) { // updateVista(vista, mLastDailyForecast); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetDailyForecastsTask)) { // mGetDailyForecastsTask = new GetDailyForecastsTask(mRepository, mCityId); // mTaskExecutor.execute(mGetDailyForecastsTask, new GetDailyForecastTaskCallback()); // } // } // } // // private void updateVista(CityDailyForecastVista vista, DailyForecast df) { // vista.setForecastDescription(capitalizeFirstLetter( // df.getDescription())); // vista.setDayTemp(NumberFormat.formatTemperature(df.getDayTemp())); // vista.setMinTemp(NumberFormat.formatTemperature(df.getMinTemp())); // vista.setMaxTemp(NumberFormat.formatTemperature(df.getMaxTemp())); // vista.setHumidity(NumberFormat.formatHumidity(df.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(df.getWindSpeed())); // } // // private String capitalizeFirstLetter(String text) { // return text.substring(0, 1).toUpperCase() + text.substring(1); // } // // private class GetDailyForecastTaskCallback extends DisplayErrorTaskCallback<List<DailyForecast>> { // public GetDailyForecastTaskCallback() { // super(CityDailyForecastPresenter.this); // } // // @Override // public void onSuccess(List<DailyForecast> list) { // DailyForecast dailyForecast = null; // if (list.size() >= mDaysFromToday + 1) { // dailyForecast = list.get(mDaysFromToday); // } // // mLastDailyForecast = dailyForecast; // // CityDailyForecastVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // if (dailyForecast != null) { // updateVista(vista, dailyForecast); // } else { // vista.displayError(R.string.error__connection); // } // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDailyForecastVista.java // public interface CityDailyForecastVista extends TaskResultVista { // // void setForecastDescription(String description); // // void setDayTemp(String temp); // // void setMinTemp(String temp); // // void setMaxTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // }
import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityDailyForecastVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityDailyForecastPresenter; import cat.ppicas.framework.ui.PresenterFactory;
mMinTemp.setText(temp); } @Override public void setMaxTemp(String temp) { mMaxTemp.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityDailyForecastPresenter createPresenter() {
// Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java // public interface ServiceContainer { // // CityRepository getCityRepository(); // // CurrentWeatherRepository getCurrentWeatherRepository(); // // DailyForecastRepository getDailyForecastRepository(); // // TaskExecutor getTaskExecutor(); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainers.java // public final class ServiceContainers { // // private ServiceContainers() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static ServiceContainer getFromApp(Context context) { // Context app = context.getApplicationContext(); // ServiceContainerProvider provider = (ServiceContainerProvider) app; // return provider.getServiceContainer(); // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/presenter/CityDailyForecastPresenter.java // public class CityDailyForecastPresenter extends Presenter<CityDailyForecastVista> { // // private final TaskExecutor mTaskExecutor; // private final DailyForecastRepository mRepository; // private final String mCityId; // private final int mDaysFromToday; // // private GetDailyForecastsTask mGetDailyForecastsTask; // private DailyForecast mLastDailyForecast; // // public CityDailyForecastPresenter(TaskExecutor taskExecutor, DailyForecastRepository repository, // String cityId, int daysFromToday) { // mTaskExecutor = taskExecutor; // mRepository = repository; // mCityId = cityId; // mDaysFromToday = daysFromToday; // } // // @Override // public void onStart(CityDailyForecastVista vista) { // if (mLastDailyForecast != null) { // updateVista(vista, mLastDailyForecast); // } else { // vista.displayLoading(true); // if (!mTaskExecutor.isRunning(mGetDailyForecastsTask)) { // mGetDailyForecastsTask = new GetDailyForecastsTask(mRepository, mCityId); // mTaskExecutor.execute(mGetDailyForecastsTask, new GetDailyForecastTaskCallback()); // } // } // } // // private void updateVista(CityDailyForecastVista vista, DailyForecast df) { // vista.setForecastDescription(capitalizeFirstLetter( // df.getDescription())); // vista.setDayTemp(NumberFormat.formatTemperature(df.getDayTemp())); // vista.setMinTemp(NumberFormat.formatTemperature(df.getMinTemp())); // vista.setMaxTemp(NumberFormat.formatTemperature(df.getMaxTemp())); // vista.setHumidity(NumberFormat.formatHumidity(df.getHumidity())); // vista.setWindSpeed(NumberFormat.formatWindSpeed(df.getWindSpeed())); // } // // private String capitalizeFirstLetter(String text) { // return text.substring(0, 1).toUpperCase() + text.substring(1); // } // // private class GetDailyForecastTaskCallback extends DisplayErrorTaskCallback<List<DailyForecast>> { // public GetDailyForecastTaskCallback() { // super(CityDailyForecastPresenter.this); // } // // @Override // public void onSuccess(List<DailyForecast> list) { // DailyForecast dailyForecast = null; // if (list.size() >= mDaysFromToday + 1) { // dailyForecast = list.get(mDaysFromToday); // } // // mLastDailyForecast = dailyForecast; // // CityDailyForecastVista vista = getVista(); // if (vista != null) { // vista.displayLoading(false); // if (dailyForecast != null) { // updateVista(vista, dailyForecast); // } else { // vista.displayError(R.string.error__connection); // } // } // } // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityDailyForecastVista.java // public interface CityDailyForecastVista extends TaskResultVista { // // void setForecastDescription(String description); // // void setDayTemp(String temp); // // void setMinTemp(String temp); // // void setMaxTemp(String temp); // // void setHumidity(String humidity); // // void setWindSpeed(String windSpeed); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/CityDailyForecastFragment.java import cat.ppicas.framework.ui.PresenterHolder; import cat.ppicas.cleanarch.ui.vista.CityDailyForecastVista; import android.app.Fragment; import android.os.Bundle; import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import android.widget.Toast; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.app.ServiceContainer; import cat.ppicas.cleanarch.app.ServiceContainers; import cat.ppicas.cleanarch.ui.presenter.CityDailyForecastPresenter; import cat.ppicas.framework.ui.PresenterFactory; mMinTemp.setText(temp); } @Override public void setMaxTemp(String temp) { mMaxTemp.setText(temp); } @Override public void setHumidity(String humidity) { mHumidity.setText(humidity); } @Override public void setWindSpeed(String windSpeed) { mWindSpeed.setText(windSpeed); } @Override public void displayLoading(boolean display) { mLoading.setVisibility(display ? View.VISIBLE : View.GONE); } @Override public void displayError(int stringResId, Object... args) { Toast.makeText(getActivity().getApplicationContext(), stringResId, Toast.LENGTH_LONG).show(); } @Override public CityDailyForecastPresenter createPresenter() {
ServiceContainer sc = ServiceContainers.getFromApp(getActivity());
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java // public interface CurrentWeatherRepository { // // CurrentWeather getCityCurrentWeather(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // }
import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.TaskExecutor;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.app; /** * Interface to be used as a repository of dependency or services required across the app. * The services provided by this container can be used to fulfill the dependencies from * other classes implementing the inversion of control principle. */ public interface ServiceContainer { CityRepository getCityRepository();
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java // public interface CurrentWeatherRepository { // // CurrentWeather getCityCurrentWeather(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.TaskExecutor; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.app; /** * Interface to be used as a repository of dependency or services required across the app. * The services provided by this container can be used to fulfill the dependencies from * other classes implementing the inversion of control principle. */ public interface ServiceContainer { CityRepository getCityRepository();
CurrentWeatherRepository getCurrentWeatherRepository();
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java // public interface CurrentWeatherRepository { // // CurrentWeather getCityCurrentWeather(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // }
import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.TaskExecutor;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.app; /** * Interface to be used as a repository of dependency or services required across the app. * The services provided by this container can be used to fulfill the dependencies from * other classes implementing the inversion of control principle. */ public interface ServiceContainer { CityRepository getCityRepository(); CurrentWeatherRepository getCurrentWeatherRepository();
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java // public interface CurrentWeatherRepository { // // CurrentWeather getCityCurrentWeather(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.TaskExecutor; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.app; /** * Interface to be used as a repository of dependency or services required across the app. * The services provided by this container can be used to fulfill the dependencies from * other classes implementing the inversion of control principle. */ public interface ServiceContainer { CityRepository getCityRepository(); CurrentWeatherRepository getCurrentWeatherRepository();
DailyForecastRepository getDailyForecastRepository();
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java // public interface CurrentWeatherRepository { // // CurrentWeather getCityCurrentWeather(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // }
import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.TaskExecutor;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.app; /** * Interface to be used as a repository of dependency or services required across the app. * The services provided by this container can be used to fulfill the dependencies from * other classes implementing the inversion of control principle. */ public interface ServiceContainer { CityRepository getCityRepository(); CurrentWeatherRepository getCurrentWeatherRepository(); DailyForecastRepository getDailyForecastRepository();
// Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CurrentWeatherRepository.java // public interface CurrentWeatherRepository { // // CurrentWeather getCityCurrentWeather(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskExecutor.java // public interface TaskExecutor { // // <R, E extends Exception> void execute(Task<R, E> task, TaskCallback<R, E> callback); // // boolean isRunning(Task<?, ?> task); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/app/ServiceContainer.java import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.cleanarch.repository.CurrentWeatherRepository; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.TaskExecutor; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.app; /** * Interface to be used as a repository of dependency or services required across the app. * The services provided by this container can be used to fulfill the dependencies from * other classes implementing the inversion of control principle. */ public interface ServiceContainer { CityRepository getCityRepository(); CurrentWeatherRepository getCurrentWeatherRepository(); DailyForecastRepository getDailyForecastRepository();
TaskExecutor getTaskExecutor();
ppicas/android-clean-architecture-mvp
core/src/main/java/cat/ppicas/cleanarch/task/GetCityTask.java
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import java.io.IOException; import cat.ppicas.cleanarch.model.City; import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; import retrofit.RetrofitError;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetCityTask implements Task<City, IOException> { private String mId;
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: core/src/main/java/cat/ppicas/cleanarch/task/GetCityTask.java import java.io.IOException; import cat.ppicas.cleanarch.model.City; import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; import retrofit.RetrofitError; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetCityTask implements Task<City, IOException> { private String mId;
private CityRepository mRepository;
ppicas/android-clean-architecture-mvp
core/src/main/java/cat/ppicas/cleanarch/task/GetCityTask.java
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import java.io.IOException; import cat.ppicas.cleanarch.model.City; import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; import retrofit.RetrofitError;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetCityTask implements Task<City, IOException> { private String mId; private CityRepository mRepository; public GetCityTask(CityRepository repository, String id) { mId = id; mRepository = repository; } @Override
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/CityRepository.java // public interface CityRepository { // // City getCity(String cityId); // // List<City> findCity(String name); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: core/src/main/java/cat/ppicas/cleanarch/task/GetCityTask.java import java.io.IOException; import cat.ppicas.cleanarch.model.City; import cat.ppicas.cleanarch.repository.CityRepository; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; import retrofit.RetrofitError; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetCityTask implements Task<City, IOException> { private String mId; private CityRepository mRepository; public GetCityTask(CityRepository repository, String id) { mId = id; mRepository = repository; } @Override
public TaskResult<City, IOException> execute() {
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/fragment/PresenterHolderFragment.java
// Path: app/src/main/java/cat/ppicas/framework/ui/Presenter.java // public abstract class Presenter<T extends Vista> { // // private T mVista; // // /** // * Returns the current bound {@link Vista} if any. // * // * @return The bound {@code Vista} or {@code null}. // */ // @Nullable // public T getVista() { // return mVista; // } // // /** // * Must be called to bind the {@link Vista} and let the {@link Presenter} know that can start // * {@code Vista} updates. Normally this method will be called from {@link Activity#onStart()} // * or from {@link Fragment#onStart()}. // * // * @param vista A {@code Vista} instance to bind. // */ // public final void start(T vista) { // mVista = vista; // onStart(vista); // } // // /** // * Must be called un unbind the {@link Vista} and let the {@link Presenter} know that must // * stop updating the {@code Vista}. Normally this method will be called from // * {@link Activity#onStop()} or from {@link Fragment#onStop()}. // */ // public final void stop() { // mVista = null; // onStop(); // } // // /** // * Called when the {@link Presenter} can start {@link Vista} updates. // * // * @param vista The bound {@code Vista}. // */ // public abstract void onStart(T vista); // // /** // * Called when the {@link Presenter} must stop {@link Vista} updates. The extending // * {@code Presenter} can override this method to provide some custom logic. // */ // public void onStop() { // } // // /** // * Called to ask the {@link Presenter} to save its current dynamic state, so it // * can later be reconstructed in a new instance of its process is // * restarted. // * // * @param state Bundle in which to place your saved state. // * @see Activity#onSaveInstanceState(Bundle) // */ // public void saveState(Bundle state) { // } // // /** // * Called to ask the {@link Presenter} to restore the previous saved state. // * // * @param state The data most recently supplied in {@link #saveState}. // * @see Activity#onRestoreInstanceState(Bundle) // */ // public void restoreState(Bundle state) { // } // // /** // * Called when this {@link Presenter} is going to be destroyed, so it has a chance to // * release resources. The extending {@code Presenter} can override this method to provide some // * custom logic. // */ // public void onDestroy() { // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // }
import android.app.Fragment; import android.os.Bundle; import java.util.HashMap; import java.util.Map; import cat.ppicas.framework.ui.Presenter; import cat.ppicas.framework.ui.PresenterFactory; import cat.ppicas.framework.ui.PresenterHolder;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.ui.fragment; public class PresenterHolderFragment extends Fragment implements PresenterHolder { private static final String STATE_PRESENTERS = "presenters";
// Path: app/src/main/java/cat/ppicas/framework/ui/Presenter.java // public abstract class Presenter<T extends Vista> { // // private T mVista; // // /** // * Returns the current bound {@link Vista} if any. // * // * @return The bound {@code Vista} or {@code null}. // */ // @Nullable // public T getVista() { // return mVista; // } // // /** // * Must be called to bind the {@link Vista} and let the {@link Presenter} know that can start // * {@code Vista} updates. Normally this method will be called from {@link Activity#onStart()} // * or from {@link Fragment#onStart()}. // * // * @param vista A {@code Vista} instance to bind. // */ // public final void start(T vista) { // mVista = vista; // onStart(vista); // } // // /** // * Must be called un unbind the {@link Vista} and let the {@link Presenter} know that must // * stop updating the {@code Vista}. Normally this method will be called from // * {@link Activity#onStop()} or from {@link Fragment#onStop()}. // */ // public final void stop() { // mVista = null; // onStop(); // } // // /** // * Called when the {@link Presenter} can start {@link Vista} updates. // * // * @param vista The bound {@code Vista}. // */ // public abstract void onStart(T vista); // // /** // * Called when the {@link Presenter} must stop {@link Vista} updates. The extending // * {@code Presenter} can override this method to provide some custom logic. // */ // public void onStop() { // } // // /** // * Called to ask the {@link Presenter} to save its current dynamic state, so it // * can later be reconstructed in a new instance of its process is // * restarted. // * // * @param state Bundle in which to place your saved state. // * @see Activity#onSaveInstanceState(Bundle) // */ // public void saveState(Bundle state) { // } // // /** // * Called to ask the {@link Presenter} to restore the previous saved state. // * // * @param state The data most recently supplied in {@link #saveState}. // * @see Activity#onRestoreInstanceState(Bundle) // */ // public void restoreState(Bundle state) { // } // // /** // * Called when this {@link Presenter} is going to be destroyed, so it has a chance to // * release resources. The extending {@code Presenter} can override this method to provide some // * custom logic. // */ // public void onDestroy() { // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/PresenterHolderFragment.java import android.app.Fragment; import android.os.Bundle; import java.util.HashMap; import java.util.Map; import cat.ppicas.framework.ui.Presenter; import cat.ppicas.framework.ui.PresenterFactory; import cat.ppicas.framework.ui.PresenterHolder; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.ui.fragment; public class PresenterHolderFragment extends Fragment implements PresenterHolder { private static final String STATE_PRESENTERS = "presenters";
private final Map<String, Presenter<?>> mPresenterMap = new HashMap<String, Presenter<?>>();
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/fragment/PresenterHolderFragment.java
// Path: app/src/main/java/cat/ppicas/framework/ui/Presenter.java // public abstract class Presenter<T extends Vista> { // // private T mVista; // // /** // * Returns the current bound {@link Vista} if any. // * // * @return The bound {@code Vista} or {@code null}. // */ // @Nullable // public T getVista() { // return mVista; // } // // /** // * Must be called to bind the {@link Vista} and let the {@link Presenter} know that can start // * {@code Vista} updates. Normally this method will be called from {@link Activity#onStart()} // * or from {@link Fragment#onStart()}. // * // * @param vista A {@code Vista} instance to bind. // */ // public final void start(T vista) { // mVista = vista; // onStart(vista); // } // // /** // * Must be called un unbind the {@link Vista} and let the {@link Presenter} know that must // * stop updating the {@code Vista}. Normally this method will be called from // * {@link Activity#onStop()} or from {@link Fragment#onStop()}. // */ // public final void stop() { // mVista = null; // onStop(); // } // // /** // * Called when the {@link Presenter} can start {@link Vista} updates. // * // * @param vista The bound {@code Vista}. // */ // public abstract void onStart(T vista); // // /** // * Called when the {@link Presenter} must stop {@link Vista} updates. The extending // * {@code Presenter} can override this method to provide some custom logic. // */ // public void onStop() { // } // // /** // * Called to ask the {@link Presenter} to save its current dynamic state, so it // * can later be reconstructed in a new instance of its process is // * restarted. // * // * @param state Bundle in which to place your saved state. // * @see Activity#onSaveInstanceState(Bundle) // */ // public void saveState(Bundle state) { // } // // /** // * Called to ask the {@link Presenter} to restore the previous saved state. // * // * @param state The data most recently supplied in {@link #saveState}. // * @see Activity#onRestoreInstanceState(Bundle) // */ // public void restoreState(Bundle state) { // } // // /** // * Called when this {@link Presenter} is going to be destroyed, so it has a chance to // * release resources. The extending {@code Presenter} can override this method to provide some // * custom logic. // */ // public void onDestroy() { // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // }
import android.app.Fragment; import android.os.Bundle; import java.util.HashMap; import java.util.Map; import cat.ppicas.framework.ui.Presenter; import cat.ppicas.framework.ui.PresenterFactory; import cat.ppicas.framework.ui.PresenterHolder;
public void onCreate(Bundle state) { super.onCreate(state); setRetainInstance(true); if (state != null) { mPresentersStates = state.getBundle(STATE_PRESENTERS); } } @Override public void onSaveInstanceState(Bundle state) { super.onSaveInstanceState(state); Bundle presentersStates = new Bundle(); for (Map.Entry<String, Presenter<?>> entry : mPresenterMap.entrySet()) { Bundle presenterState = new Bundle(); entry.getValue().saveState(presenterState); presentersStates.putBundle(entry.getKey(), presenterState); } state.putBundle(STATE_PRESENTERS, presentersStates); } @Override public void onDestroy() { super.onDestroy(); for (Presenter<?> presenter : mPresenterMap.values()) { presenter.onDestroy(); } } @Override
// Path: app/src/main/java/cat/ppicas/framework/ui/Presenter.java // public abstract class Presenter<T extends Vista> { // // private T mVista; // // /** // * Returns the current bound {@link Vista} if any. // * // * @return The bound {@code Vista} or {@code null}. // */ // @Nullable // public T getVista() { // return mVista; // } // // /** // * Must be called to bind the {@link Vista} and let the {@link Presenter} know that can start // * {@code Vista} updates. Normally this method will be called from {@link Activity#onStart()} // * or from {@link Fragment#onStart()}. // * // * @param vista A {@code Vista} instance to bind. // */ // public final void start(T vista) { // mVista = vista; // onStart(vista); // } // // /** // * Must be called un unbind the {@link Vista} and let the {@link Presenter} know that must // * stop updating the {@code Vista}. Normally this method will be called from // * {@link Activity#onStop()} or from {@link Fragment#onStop()}. // */ // public final void stop() { // mVista = null; // onStop(); // } // // /** // * Called when the {@link Presenter} can start {@link Vista} updates. // * // * @param vista The bound {@code Vista}. // */ // public abstract void onStart(T vista); // // /** // * Called when the {@link Presenter} must stop {@link Vista} updates. The extending // * {@code Presenter} can override this method to provide some custom logic. // */ // public void onStop() { // } // // /** // * Called to ask the {@link Presenter} to save its current dynamic state, so it // * can later be reconstructed in a new instance of its process is // * restarted. // * // * @param state Bundle in which to place your saved state. // * @see Activity#onSaveInstanceState(Bundle) // */ // public void saveState(Bundle state) { // } // // /** // * Called to ask the {@link Presenter} to restore the previous saved state. // * // * @param state The data most recently supplied in {@link #saveState}. // * @see Activity#onRestoreInstanceState(Bundle) // */ // public void restoreState(Bundle state) { // } // // /** // * Called when this {@link Presenter} is going to be destroyed, so it has a chance to // * release resources. The extending {@code Presenter} can override this method to provide some // * custom logic. // */ // public void onDestroy() { // } // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterFactory.java // public interface PresenterFactory<T extends Presenter<?>> { // // T createPresenter(); // // String getPresenterTag(); // // } // // Path: app/src/main/java/cat/ppicas/framework/ui/PresenterHolder.java // public interface PresenterHolder { // // <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory); // // void destroyPresenter(PresenterFactory<?> presenterFactory); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/fragment/PresenterHolderFragment.java import android.app.Fragment; import android.os.Bundle; import java.util.HashMap; import java.util.Map; import cat.ppicas.framework.ui.Presenter; import cat.ppicas.framework.ui.PresenterFactory; import cat.ppicas.framework.ui.PresenterHolder; public void onCreate(Bundle state) { super.onCreate(state); setRetainInstance(true); if (state != null) { mPresentersStates = state.getBundle(STATE_PRESENTERS); } } @Override public void onSaveInstanceState(Bundle state) { super.onSaveInstanceState(state); Bundle presentersStates = new Bundle(); for (Map.Entry<String, Presenter<?>> entry : mPresenterMap.entrySet()) { Bundle presenterState = new Bundle(); entry.getValue().saveState(presenterState); presentersStates.putBundle(entry.getKey(), presenterState); } state.putBundle(STATE_PRESENTERS, presentersStates); } @Override public void onDestroy() { super.onDestroy(); for (Presenter<?> presenter : mPresenterMap.values()) { presenter.onDestroy(); } } @Override
public <T extends Presenter<?>> T getOrCreatePresenter(PresenterFactory<T> presenterFactory) {
ppicas/android-clean-architecture-mvp
app/src/main/java/cat/ppicas/cleanarch/ui/view/CityListItemView.java
// Path: app/src/main/java/cat/ppicas/cleanarch/text/NumberFormat.java // public final class NumberFormat { // // private static final java.text.NumberFormat DECIMAL_FORMATTER // = java.text.NumberFormat.getInstance(); // // static { // DECIMAL_FORMATTER.setMaximumFractionDigits(2); // } // // private NumberFormat() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static String formatDecimal(double num) { // return DECIMAL_FORMATTER.format(num); // } // // public static String formatTemperature(double temp) { // return DECIMAL_FORMATTER.format(temp) + "º"; // } // // public static String formatHumidity(double humidity) { // return Math.round(humidity) + "%"; // } // // public static String formatWindSpeed(double windSpeed) { // return DECIMAL_FORMATTER.format(windSpeed) + " m/s"; // } // // public static String formatElevation(int elevation) { // return elevation + "m"; // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityListItemVista.java // public interface CityListItemVista extends Vista { // // void setCityName(String name); // // void setCountry(String country); // // void setCurrentTemp(String temp); // // void setLoadingElevation(boolean loading); // // void setElevation(int elevation); // // }
import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.TextView; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.text.NumberFormat; import cat.ppicas.cleanarch.ui.vista.CityListItemVista;
mTempView = (TextView) findViewById(R.id.city_list_item__temp); mElevationView = (TextView) findViewById(R.id.city_list_item__elevation); } @Override public void setCityName(String name) { mName = name; updateNameView(); } @Override public void setCountry(String country) { mCountry = country; updateNameView(); } @Override public void setCurrentTemp(String temp) { mTempView.setText(temp); } @Override public void setLoadingElevation(boolean loading) { if (loading) { mElevationView.setText(getContext().getString(R.string.city_list_item__elevation)); } } @Override public void setElevation(int elevation) {
// Path: app/src/main/java/cat/ppicas/cleanarch/text/NumberFormat.java // public final class NumberFormat { // // private static final java.text.NumberFormat DECIMAL_FORMATTER // = java.text.NumberFormat.getInstance(); // // static { // DECIMAL_FORMATTER.setMaximumFractionDigits(2); // } // // private NumberFormat() { // throw new RuntimeException("Instances are not allowed for this class"); // } // // public static String formatDecimal(double num) { // return DECIMAL_FORMATTER.format(num); // } // // public static String formatTemperature(double temp) { // return DECIMAL_FORMATTER.format(temp) + "º"; // } // // public static String formatHumidity(double humidity) { // return Math.round(humidity) + "%"; // } // // public static String formatWindSpeed(double windSpeed) { // return DECIMAL_FORMATTER.format(windSpeed) + " m/s"; // } // // public static String formatElevation(int elevation) { // return elevation + "m"; // } // } // // Path: app/src/main/java/cat/ppicas/cleanarch/ui/vista/CityListItemVista.java // public interface CityListItemVista extends Vista { // // void setCityName(String name); // // void setCountry(String country); // // void setCurrentTemp(String temp); // // void setLoadingElevation(boolean loading); // // void setElevation(int elevation); // // } // Path: app/src/main/java/cat/ppicas/cleanarch/ui/view/CityListItemView.java import android.content.Context; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.TextView; import cat.ppicas.cleanarch.R; import cat.ppicas.cleanarch.text.NumberFormat; import cat.ppicas.cleanarch.ui.vista.CityListItemVista; mTempView = (TextView) findViewById(R.id.city_list_item__temp); mElevationView = (TextView) findViewById(R.id.city_list_item__elevation); } @Override public void setCityName(String name) { mName = name; updateNameView(); } @Override public void setCountry(String country) { mCountry = country; updateNameView(); } @Override public void setCurrentTemp(String temp) { mTempView.setText(temp); } @Override public void setLoadingElevation(boolean loading) { if (loading) { mElevationView.setText(getContext().getString(R.string.city_list_item__elevation)); } } @Override public void setElevation(int elevation) {
mElevationView.setText(NumberFormat.formatElevation(elevation));
ppicas/android-clean-architecture-mvp
core/src/main/java/cat/ppicas/cleanarch/task/GetElevationTask.java
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/NoException.java // public final class NoException extends RuntimeException { // // private NoException() { // // Private constructor to ensure this class is never instantiated // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import cat.ppicas.cleanarch.model.City; import cat.ppicas.framework.task.NoException; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetElevationTask implements Task<Integer, NoException> { @SuppressWarnings("FieldCanBeLocal")
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/NoException.java // public final class NoException extends RuntimeException { // // private NoException() { // // Private constructor to ensure this class is never instantiated // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: core/src/main/java/cat/ppicas/cleanarch/task/GetElevationTask.java import cat.ppicas.cleanarch.model.City; import cat.ppicas.framework.task.NoException; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetElevationTask implements Task<Integer, NoException> { @SuppressWarnings("FieldCanBeLocal")
private City mCity;
ppicas/android-clean-architecture-mvp
core/src/main/java/cat/ppicas/cleanarch/task/GetElevationTask.java
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/NoException.java // public final class NoException extends RuntimeException { // // private NoException() { // // Private constructor to ensure this class is never instantiated // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import cat.ppicas.cleanarch.model.City; import cat.ppicas.framework.task.NoException; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetElevationTask implements Task<Integer, NoException> { @SuppressWarnings("FieldCanBeLocal") private City mCity; private volatile boolean mCanceled; public GetElevationTask(City city) { mCity = city; } @Override
// Path: core/src/main/java/cat/ppicas/cleanarch/model/City.java // public class City { // // private String mId; // private String mName; // private String mCountry; // private CurrentWeatherPreview mCurrentWeatherPreview; // // public City(String id, String name, String country) { // mId = id; // mName = name; // mCountry = country; // } // // public City(String id, String name, String country, // CurrentWeatherPreview currentWeatherPreview) { // mId = id; // mName = name; // mCountry = country; // mCurrentWeatherPreview = currentWeatherPreview; // } // // public String getId() { // return mId; // } // // public String getName() { // return mName; // } // // public String getCountry() { // return mCountry; // } // // public CurrentWeatherPreview getCurrentWeatherPreview() { // return mCurrentWeatherPreview; // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/NoException.java // public final class NoException extends RuntimeException { // // private NoException() { // // Private constructor to ensure this class is never instantiated // } // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: core/src/main/java/cat/ppicas/cleanarch/task/GetElevationTask.java import cat.ppicas.cleanarch.model.City; import cat.ppicas.framework.task.NoException; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetElevationTask implements Task<Integer, NoException> { @SuppressWarnings("FieldCanBeLocal") private City mCity; private volatile boolean mCanceled; public GetElevationTask(City city) { mCity = city; } @Override
public TaskResult<Integer, NoException> execute() {
ppicas/android-clean-architecture-mvp
core/src/main/java/cat/ppicas/cleanarch/task/GetDailyForecastsTask.java
// Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java // public class DailyForecast { // // private String mCityId; // private Date mDate; // private String mDescription; // private double mDayTemp; // private double mMinTemp; // private double mMaxTemp; // private double mHumidity; // private double mWindSpeed; // // public DailyForecast(String cityId, Date date, String description, double dayTemp, // double minTemp, double maxTemp, double humidity, double windSpeed) { // mCityId = cityId; // mDate = date; // mDescription = description; // mDayTemp = dayTemp; // mMinTemp = minTemp; // mMaxTemp = maxTemp; // mHumidity = humidity; // mWindSpeed = windSpeed; // } // // public String getCityId() { // return mCityId; // } // // public Date getDate() { // return mDate; // } // // public String getDescription() { // return mDescription; // } // // public double getDayTemp() { // return mDayTemp; // } // // public double getMinTemp() { // return mMinTemp; // } // // public double getMaxTemp() { // return mMaxTemp; // } // // public double getHumidity() { // return mHumidity; // } // // public double getWindSpeed() { // return mWindSpeed; // } // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // }
import java.io.IOException; import java.util.List; import cat.ppicas.cleanarch.model.DailyForecast; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; import retrofit.RetrofitError;
/* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetDailyForecastsTask implements Task<List<DailyForecast>, IOException> { private DailyForecastRepository mRepository; private String mCityId; public GetDailyForecastsTask(DailyForecastRepository repository, String cityId) { mRepository = repository; mCityId = cityId; } @Override
// Path: core/src/main/java/cat/ppicas/cleanarch/model/DailyForecast.java // public class DailyForecast { // // private String mCityId; // private Date mDate; // private String mDescription; // private double mDayTemp; // private double mMinTemp; // private double mMaxTemp; // private double mHumidity; // private double mWindSpeed; // // public DailyForecast(String cityId, Date date, String description, double dayTemp, // double minTemp, double maxTemp, double humidity, double windSpeed) { // mCityId = cityId; // mDate = date; // mDescription = description; // mDayTemp = dayTemp; // mMinTemp = minTemp; // mMaxTemp = maxTemp; // mHumidity = humidity; // mWindSpeed = windSpeed; // } // // public String getCityId() { // return mCityId; // } // // public Date getDate() { // return mDate; // } // // public String getDescription() { // return mDescription; // } // // public double getDayTemp() { // return mDayTemp; // } // // public double getMinTemp() { // return mMinTemp; // } // // public double getMaxTemp() { // return mMaxTemp; // } // // public double getHumidity() { // return mHumidity; // } // // public double getWindSpeed() { // return mWindSpeed; // } // } // // Path: core/src/main/java/cat/ppicas/cleanarch/repository/DailyForecastRepository.java // public interface DailyForecastRepository { // // List<DailyForecast> getDailyForecasts(String cityId); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/Task.java // public interface Task<R, E extends Exception> { // // TaskResult<R, E> execute(); // // } // // Path: core/src/main/java/cat/ppicas/framework/task/TaskResult.java // public class TaskResult<R, E extends Exception> { // // private final R mResult; // // private final E mError; // // private final boolean mCanceled; // // public static <R, E extends Exception> TaskResult<R, E> newSuccessResult(R result) { // return new TaskResult<>(result, null, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newErrorResult(E error) { // return new TaskResult<>(null, error, false); // } // // public static <R, E extends Exception> TaskResult<R, E> newCanceledResult() { // return new TaskResult<>(null, null, true); // } // // TaskResult(R result, E error, boolean canceled) { // mResult = result; // mError = error; // mCanceled = canceled; // } // // public R getResult() { // return mResult; // } // // public E getError() { // return mError; // } // // public boolean isSuccess() { // return !mCanceled && mError == null; // } // // public boolean isCanceled() { // return mCanceled; // } // } // Path: core/src/main/java/cat/ppicas/cleanarch/task/GetDailyForecastsTask.java import java.io.IOException; import java.util.List; import cat.ppicas.cleanarch.model.DailyForecast; import cat.ppicas.cleanarch.repository.DailyForecastRepository; import cat.ppicas.framework.task.Task; import cat.ppicas.framework.task.TaskResult; import retrofit.RetrofitError; /* * Copyright (C) 2015 Pau Picas Sans <pau.picas@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package cat.ppicas.cleanarch.task; public class GetDailyForecastsTask implements Task<List<DailyForecast>, IOException> { private DailyForecastRepository mRepository; private String mCityId; public GetDailyForecastsTask(DailyForecastRepository repository, String cityId) { mRepository = repository; mCityId = cityId; } @Override
public TaskResult<List<DailyForecast>, IOException> execute() {
stefansavev/random-projections-at-berlinbuzzwords
src/test/scala/com/stefansavev/fuzzysearchtest/GloveTest.java
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // }
import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Random;
package com.stefansavev.fuzzysearchtest; public class GloveTest { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); if (parts.length != (1 + numDimensions)) { throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + " such as: 'the 0.020341 0.011216 0.099383 0.102027 0.041391 -0.010218 "); } String word = parts[0]; double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i + 1]); } return new SimilaritySearchItem(word, -1, vec); //ignore the label } static void buildIndex(String inputFile, String outputIndexFile, int numTrees) throws IOException, InvalidDataPointException { int dataDimension = 100; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // } // Path: src/test/scala/com/stefansavev/fuzzysearchtest/GloveTest.java import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Random; package com.stefansavev.fuzzysearchtest; public class GloveTest { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); if (parts.length != (1 + numDimensions)) { throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + " such as: 'the 0.020341 0.011216 0.099383 0.102027 0.041391 -0.010218 "); } String word = parts[0]; double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i + 1]); } return new SimilaritySearchItem(word, -1, vec); //ignore the label } static void buildIndex(String inputFile, String outputIndexFile, int numTrees) throws IOException, InvalidDataPointException { int dataDimension = 100; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
VectorTypes.uncorrelatedFeatures(dataDimension, VectorType.StorageSize.Double),
stefansavev/random-projections-at-berlinbuzzwords
src/test/scala/com/stefansavev/fuzzysearchtest/MnistTest.java
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // }
import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Random;
package com.stefansavev.fuzzysearchtest; public class MnistTest { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] tokens = line.split(","); int label = Integer.parseInt(tokens[0]); double[] values = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { values[i] = Double.parseDouble(tokens[i + 1]); } String lineNumberStr = Integer.toString(lineNumber); String name = lineNumberStr + "#" + lineNumberStr; return new SimilaritySearchItem(name, label, values); } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 100; int numTrees = 10; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // } // Path: src/test/scala/com/stefansavev/fuzzysearchtest/MnistTest.java import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Random; package com.stefansavev.fuzzysearchtest; public class MnistTest { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] tokens = line.split(","); int label = Integer.parseInt(tokens[0]); double[] values = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { values[i] = Double.parseDouble(tokens[i + 1]); } String lineNumberStr = Integer.toString(lineNumber); String name = lineNumberStr + "#" + lineNumberStr; return new SimilaritySearchItem(name, label, values); } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 100; int numTrees = 10; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
VectorTypes.uncorrelatedFeatures(dataDimension, VectorType.StorageSize.Double),
stefansavev/random-projections-at-berlinbuzzwords
src/test/scala/com/stefansavev/fuzzysearchtest/WikipediaLSI.java
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // }
import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; import java.util.Random;
package com.stefansavev.fuzzysearchtest; public class WikipediaLSI { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); //if (parts.length != (numDimensions)){ // throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + " such as: 'the 0.020341 0.011216 0.099383 0.102027 0.041391 -0.010218 "); //} double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i]); } return new SimilaritySearchItem(Integer.toString(lineNumber), -1, vec); //ignore the label } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 128; int numTrees = 50; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // } // Path: src/test/scala/com/stefansavev/fuzzysearchtest/WikipediaLSI.java import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; import java.util.Random; package com.stefansavev.fuzzysearchtest; public class WikipediaLSI { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); //if (parts.length != (numDimensions)){ // throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + " such as: 'the 0.020341 0.011216 0.099383 0.102027 0.041391 -0.010218 "); //} double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i]); } return new SimilaritySearchItem(Integer.toString(lineNumber), -1, vec); //ignore the label } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 128; int numTrees = 50; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
VectorTypes.uncorrelatedFeatures(dataDimension, VectorType.StorageSize.SingleByte),
stefansavev/random-projections-at-berlinbuzzwords
src/test/scala/com/stefansavev/fuzzysearchtest/WordVecTest.java
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // }
import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.randomprojections.evaluation.RecallEvaluator; import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Random;
package com.stefansavev.fuzzysearchtest; public class WordVecTest { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); if (parts.length != (1 + numDimensions)) { throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + " such as: 'the 0.020341 0.011216 0.099383 0.102027 0.041391 -0.010218 "); } String word = parts[0]; double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i + 1]); } return new SimilaritySearchItem(word, -1, vec); //ignore the label } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 200; int numTrees = 50; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder( outputIndexFile,
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // } // Path: src/test/scala/com/stefansavev/fuzzysearchtest/WordVecTest.java import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.randomprojections.evaluation.RecallEvaluator; import com.stefansavev.similaritysearch.*; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Random; package com.stefansavev.fuzzysearchtest; public class WordVecTest { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); if (parts.length != (1 + numDimensions)) { throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + " such as: 'the 0.020341 0.011216 0.099383 0.102027 0.041391 -0.010218 "); } String word = parts[0]; double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i + 1]); } return new SimilaritySearchItem(word, -1, vec); //ignore the label } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 200; int numTrees = 50; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder( outputIndexFile,
VectorTypes.uncorrelatedFeatures(dataDimension, VectorType.StorageSize.Double),
stefansavev/random-projections-at-berlinbuzzwords
src/test/scala/com/stefansavev/fuzzysearchtest/Cifar100Parts.java
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // }
import com.stefansavev.similaritysearch.*; import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; import java.util.Random;
package com.stefansavev.fuzzysearchtest; public class Cifar100Parts { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); //System.out.println("Parts len: " + parts.length); if (parts.length != 67) { return null; } if (parts.length != (3 + numDimensions)) { throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + line); } String fileIndex = parts[0]; String partId = parts[1]; int labelId = Integer.parseInt(parts[2]); double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i + 1]); } return new SimilaritySearchItem(fileIndex + "_" + partId, labelId, vec); } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 64; int numTrees = 50; //150; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
// Path: src/main/scala/com/stefansavev/similaritysearch/implementation/VectorTypes.java // public class VectorTypes { // public static VectorType uncorrelatedFeatures(int dimension, VectorType.StorageSize storageSize){ // return new VectorType.UncorrelatedFeatures(dimension, storageSize); // } // } // Path: src/test/scala/com/stefansavev/fuzzysearchtest/Cifar100Parts.java import com.stefansavev.similaritysearch.*; import com.stefansavev.randomprojections.actors.Application; import com.stefansavev.similaritysearch.implementation.VectorTypes; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; import java.util.Random; package com.stefansavev.fuzzysearchtest; public class Cifar100Parts { static SimilaritySearchItem parseItem(int lineNumber, String line, int numDimensions) { String[] parts = line.split("\\s+"); //System.out.println("Parts len: " + parts.length); if (parts.length != 67) { return null; } if (parts.length != (3 + numDimensions)) { throw new IllegalStateException("Invalid data format. Expecting data of dimension " + numDimensions + line); } String fileIndex = parts[0]; String partId = parts[1]; int labelId = Integer.parseInt(parts[2]); double[] vec = new double[numDimensions]; for (int i = 0; i < numDimensions; i++) { vec[i] = Double.parseDouble(parts[i + 1]); } return new SimilaritySearchItem(fileIndex + "_" + partId, labelId, vec); } static void buildIndex(String inputFile, String outputIndexFile) throws IOException, InvalidDataPointException { int dataDimension = 64; int numTrees = 50; //150; //create an indexer SimilaritySearchIndexBuilder indexBuilder = new SimilaritySearchIndexBuilder(outputIndexFile,
VectorTypes.uncorrelatedFeatures(dataDimension, VectorType.StorageSize.TwoBytes),
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/ReviewMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_AUTHOR = 5; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_CONTENT = 6; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_URL = 7;
import static work.technie.popularmovies.Constants.COL_REVIEW_CONTENT; import static work.technie.popularmovies.Constants.COL_REVIEW_URL; import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.Locale; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_REVIEW_AUTHOR;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class ReviewMovieAdapter extends RecyclerView.Adapter<ReviewMovieAdapter.ViewHolder> { private final Cursor cursor; public ReviewMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_review_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder viewHolder, int position) { cursor.moveToPosition(position);
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_AUTHOR = 5; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_CONTENT = 6; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_URL = 7; // Path: app/src/main/java/work/technie/popularmovies/adapter/ReviewMovieAdapter.java import static work.technie.popularmovies.Constants.COL_REVIEW_CONTENT; import static work.technie.popularmovies.Constants.COL_REVIEW_URL; import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.Locale; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_REVIEW_AUTHOR; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class ReviewMovieAdapter extends RecyclerView.Adapter<ReviewMovieAdapter.ViewHolder> { private final Cursor cursor; public ReviewMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_review_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder viewHolder, int position) { cursor.moveToPosition(position);
final String author_name = cursor.getString(COL_REVIEW_AUTHOR);
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/ReviewMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_AUTHOR = 5; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_CONTENT = 6; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_URL = 7;
import static work.technie.popularmovies.Constants.COL_REVIEW_CONTENT; import static work.technie.popularmovies.Constants.COL_REVIEW_URL; import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.Locale; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_REVIEW_AUTHOR;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class ReviewMovieAdapter extends RecyclerView.Adapter<ReviewMovieAdapter.ViewHolder> { private final Cursor cursor; public ReviewMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_review_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String author_name = cursor.getString(COL_REVIEW_AUTHOR);
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_AUTHOR = 5; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_CONTENT = 6; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_URL = 7; // Path: app/src/main/java/work/technie/popularmovies/adapter/ReviewMovieAdapter.java import static work.technie.popularmovies.Constants.COL_REVIEW_CONTENT; import static work.technie.popularmovies.Constants.COL_REVIEW_URL; import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.Locale; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_REVIEW_AUTHOR; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class ReviewMovieAdapter extends RecyclerView.Adapter<ReviewMovieAdapter.ViewHolder> { private final Cursor cursor; public ReviewMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_review_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String author_name = cursor.getString(COL_REVIEW_AUTHOR);
final String content = cursor.getString(COL_REVIEW_CONTENT);
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/ReviewMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_AUTHOR = 5; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_CONTENT = 6; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_URL = 7;
import static work.technie.popularmovies.Constants.COL_REVIEW_CONTENT; import static work.technie.popularmovies.Constants.COL_REVIEW_URL; import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.Locale; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_REVIEW_AUTHOR;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class ReviewMovieAdapter extends RecyclerView.Adapter<ReviewMovieAdapter.ViewHolder> { private final Cursor cursor; public ReviewMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_review_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String author_name = cursor.getString(COL_REVIEW_AUTHOR); final String content = cursor.getString(COL_REVIEW_CONTENT);
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_AUTHOR = 5; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_CONTENT = 6; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_REVIEW_URL = 7; // Path: app/src/main/java/work/technie/popularmovies/adapter/ReviewMovieAdapter.java import static work.technie.popularmovies.Constants.COL_REVIEW_CONTENT; import static work.technie.popularmovies.Constants.COL_REVIEW_URL; import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import java.util.Locale; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_REVIEW_AUTHOR; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class ReviewMovieAdapter extends RecyclerView.Adapter<ReviewMovieAdapter.ViewHolder> { private final Cursor cursor; public ReviewMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_review_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String author_name = cursor.getString(COL_REVIEW_AUTHOR); final String content = cursor.getString(COL_REVIEW_CONTENT);
final String url = cursor.getString(COL_REVIEW_URL);
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3;
import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context;
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3; // Path: app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context;
private ViewHolderUtil.SetOnClickListener listener;
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3;
import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context; private ViewHolderUtil.SetOnClickListener listener; public VideoMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_video_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder viewHolder, int position) { cursor.moveToPosition(position);
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3; // Path: app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context; private ViewHolderUtil.SetOnClickListener listener; public VideoMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_video_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder viewHolder, int position) { cursor.moveToPosition(position);
final String trailer_name = cursor.getString(COL_VIDEOS_NAME);
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3;
import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context; private ViewHolderUtil.SetOnClickListener listener; public VideoMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_video_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String trailer_name = cursor.getString(COL_VIDEOS_NAME);
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3; // Path: app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context; private ViewHolderUtil.SetOnClickListener listener; public VideoMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_video_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String trailer_name = cursor.getString(COL_VIDEOS_NAME);
final String source = cursor.getString(COL_VIDEOS_KEY);
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3;
import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context; private ViewHolderUtil.SetOnClickListener listener; public VideoMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_video_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String trailer_name = cursor.getString(COL_VIDEOS_NAME); final String source = cursor.getString(COL_VIDEOS_KEY); viewHolder.trailer.setText(trailer_name); final String BASE_URL = "http://img.youtube.com/vi/"; final String url = BASE_URL + source + "/0.jpg"; Picasso .with(context) .load(url) .networkPolicy(NetworkPolicy.OFFLINE)
// Path: app/src/main/java/work/technie/popularmovies/utils/RoundedTransformation.java // public class RoundedTransformation implements com.squareup.picasso.Transformation { // private final int radius; // private final int margin; // dp // private final String key; // // // radius is corner radii in dp // // margin is the board in dp // public RoundedTransformation(final int radius, final int margin) { // this.radius = radius; // this.margin = margin; // this.key = "rounded(radius=" + radius + ", margin=" + margin + ")"; // } // // @Override // public Bitmap transform(final Bitmap source) { // final Paint paint = new Paint(); // paint.setAntiAlias(true); // paint.setShader(new BitmapShader(source, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP)); // // Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(output); // canvas.drawRoundRect(new RectF(margin, margin, source.getWidth() - margin, source.getHeight() - margin), radius, radius, paint); // // if (!source.equals(output)) { // source.recycle(); // } // // return output; // } // // @Override // public String key() { // return this.key; // } // } // // Path: app/src/main/java/work/technie/popularmovies/utils/ViewHolderUtil.java // public class ViewHolderUtil { // // /** // * to handle click listener // */ // public interface SetOnClickListener { // void onItemClick(int position); // } // } // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_KEY = 2; // // Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_VIDEOS_NAME = 3; // Path: app/src/main/java/work/technie/popularmovies/adapter/VideoMovieAdapter.java import work.technie.popularmovies.utils.RoundedTransformation; import work.technie.popularmovies.utils.ViewHolderUtil; import static work.technie.popularmovies.Constants.COL_VIDEOS_KEY; import static work.technie.popularmovies.Constants.COL_VIDEOS_NAME; import android.content.Context; import android.database.Cursor; 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.squareup.picasso.Callback; import com.squareup.picasso.NetworkPolicy; import com.squareup.picasso.Picasso; import work.technie.popularmovies.R; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 27/12/15. */ public class VideoMovieAdapter extends RecyclerView.Adapter<VideoMovieAdapter.ViewHolder> { private final Cursor cursor; private Context context; private ViewHolderUtil.SetOnClickListener listener; public VideoMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_video_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(final ViewHolder viewHolder, int position) { cursor.moveToPosition(position); final String trailer_name = cursor.getString(COL_VIDEOS_NAME); final String source = cursor.getString(COL_VIDEOS_KEY); viewHolder.trailer.setText(trailer_name); final String BASE_URL = "http://img.youtube.com/vi/"; final String url = BASE_URL + source + "/0.jpg"; Picasso .with(context) .load(url) .networkPolicy(NetworkPolicy.OFFLINE)
.transform(new RoundedTransformation(10, 10))
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/asyntask/FetchPeopleDetail.java
// Path: app/src/main/java/work/technie/popularmovies/data/MovieContract.java // public static final class People implements BaseColumns { // // public static final String TABLE_NAME = "people"; // // public static final String ADULT = "adult"; // public static final String BIOGRAPHY = "biography"; // public static final String BIRTHDAY = "birthday"; // public static final String DEATHDAY = "deathday"; // public static final String GENDER = "gender"; // public static final String HOMEPAGE = "homepage"; // public static final String ID = "id"; // public static final String NAME = "name"; // public static final String PLACE_OF_BIRTH = "place_of_birth"; // public static final String POPULARITY = "popularity"; // public static final String PROFILE_PATH = "profile_path"; // // public static final Uri CONTENT_URI = // BASE_CONTENT_URI.buildUpon().appendPath(PATH_PEOPLE).build(); // // static final String CONTENT_TYPE = // ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // static final String CONTENT_ITEM_TYPE = // ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // // static Uri buildPeopleUri(long id) { // return ContentUris.withAppendedId(CONTENT_URI, id); // } // // //content://work....../people/peopleId // public static Uri buildPeopleUriWithPeopleId(String peopleId) { // return CONTENT_URI.buildUpon().appendPath(peopleId).build(); // } // // public static Uri buildPersonUri() { // return CONTENT_URI.buildUpon().build(); // } // // public static String getIDFromUri(Uri uri) { // return uri.getPathSegments().get(1); // } // // } // // Path: app/src/main/java/work/technie/popularmovies/utils/AsyncResponse.java // public interface AsyncResponse { // void onFinish(boolean isData); // }
import work.technie.popularmovies.data.MovieContract.People; import work.technie.popularmovies.utils.AsyncResponse; import android.content.ContentValues; import android.content.Context; import android.net.Uri; import android.os.AsyncTask; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import work.technie.popularmovies.BuildConfig;
package work.technie.popularmovies.asyntask; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Created by anupam on 16/12/16. */ public class FetchPeopleDetail extends AsyncTask<String, Void, Void> { private final String LOG_TAG = FetchTVMovieTask.class.getSimpleName(); private final Context mContext;
// Path: app/src/main/java/work/technie/popularmovies/data/MovieContract.java // public static final class People implements BaseColumns { // // public static final String TABLE_NAME = "people"; // // public static final String ADULT = "adult"; // public static final String BIOGRAPHY = "biography"; // public static final String BIRTHDAY = "birthday"; // public static final String DEATHDAY = "deathday"; // public static final String GENDER = "gender"; // public static final String HOMEPAGE = "homepage"; // public static final String ID = "id"; // public static final String NAME = "name"; // public static final String PLACE_OF_BIRTH = "place_of_birth"; // public static final String POPULARITY = "popularity"; // public static final String PROFILE_PATH = "profile_path"; // // public static final Uri CONTENT_URI = // BASE_CONTENT_URI.buildUpon().appendPath(PATH_PEOPLE).build(); // // static final String CONTENT_TYPE = // ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // static final String CONTENT_ITEM_TYPE = // ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // // static Uri buildPeopleUri(long id) { // return ContentUris.withAppendedId(CONTENT_URI, id); // } // // //content://work....../people/peopleId // public static Uri buildPeopleUriWithPeopleId(String peopleId) { // return CONTENT_URI.buildUpon().appendPath(peopleId).build(); // } // // public static Uri buildPersonUri() { // return CONTENT_URI.buildUpon().build(); // } // // public static String getIDFromUri(Uri uri) { // return uri.getPathSegments().get(1); // } // // } // // Path: app/src/main/java/work/technie/popularmovies/utils/AsyncResponse.java // public interface AsyncResponse { // void onFinish(boolean isData); // } // Path: app/src/main/java/work/technie/popularmovies/asyntask/FetchPeopleDetail.java import work.technie.popularmovies.data.MovieContract.People; import work.technie.popularmovies.utils.AsyncResponse; import android.content.ContentValues; import android.content.Context; import android.net.Uri; import android.os.AsyncTask; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import work.technie.popularmovies.BuildConfig; package work.technie.popularmovies.asyntask; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Created by anupam on 16/12/16. */ public class FetchPeopleDetail extends AsyncTask<String, Void, Void> { private final String LOG_TAG = FetchTVMovieTask.class.getSimpleName(); private final Context mContext;
public AsyncResponse response = null;
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/asyntask/FetchPeopleDetail.java
// Path: app/src/main/java/work/technie/popularmovies/data/MovieContract.java // public static final class People implements BaseColumns { // // public static final String TABLE_NAME = "people"; // // public static final String ADULT = "adult"; // public static final String BIOGRAPHY = "biography"; // public static final String BIRTHDAY = "birthday"; // public static final String DEATHDAY = "deathday"; // public static final String GENDER = "gender"; // public static final String HOMEPAGE = "homepage"; // public static final String ID = "id"; // public static final String NAME = "name"; // public static final String PLACE_OF_BIRTH = "place_of_birth"; // public static final String POPULARITY = "popularity"; // public static final String PROFILE_PATH = "profile_path"; // // public static final Uri CONTENT_URI = // BASE_CONTENT_URI.buildUpon().appendPath(PATH_PEOPLE).build(); // // static final String CONTENT_TYPE = // ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // static final String CONTENT_ITEM_TYPE = // ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // // static Uri buildPeopleUri(long id) { // return ContentUris.withAppendedId(CONTENT_URI, id); // } // // //content://work....../people/peopleId // public static Uri buildPeopleUriWithPeopleId(String peopleId) { // return CONTENT_URI.buildUpon().appendPath(peopleId).build(); // } // // public static Uri buildPersonUri() { // return CONTENT_URI.buildUpon().build(); // } // // public static String getIDFromUri(Uri uri) { // return uri.getPathSegments().get(1); // } // // } // // Path: app/src/main/java/work/technie/popularmovies/utils/AsyncResponse.java // public interface AsyncResponse { // void onFinish(boolean isData); // }
import work.technie.popularmovies.data.MovieContract.People; import work.technie.popularmovies.utils.AsyncResponse; import android.content.ContentValues; import android.content.Context; import android.net.Uri; import android.os.AsyncTask; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import work.technie.popularmovies.BuildConfig;
package work.technie.popularmovies.asyntask; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Created by anupam on 16/12/16. */ public class FetchPeopleDetail extends AsyncTask<String, Void, Void> { private final String LOG_TAG = FetchTVMovieTask.class.getSimpleName(); private final Context mContext; public AsyncResponse response = null; private boolean DEBUG = true; public FetchPeopleDetail(Context context) { mContext = context; } /** * Take the String representing the complete movie list in JSON Format and * pull out the data we need to construct the Strings needed for the wireframes. * <p> * Fortunately parsing is easy: constructor takes the JSON string and converts it * into an Object hierarchy for us. */ private void getMovieDataFromJson(String movieJsonStr) throws JSONException { try { JSONObject profileJson = new JSONObject(movieJsonStr); ContentValues[] cvArray = new ContentValues[1]; String adult; String biography; String birthday; String deathday; String gender; String homepage; String id; String name; String place_of_birth; String popularity; String profile_path;
// Path: app/src/main/java/work/technie/popularmovies/data/MovieContract.java // public static final class People implements BaseColumns { // // public static final String TABLE_NAME = "people"; // // public static final String ADULT = "adult"; // public static final String BIOGRAPHY = "biography"; // public static final String BIRTHDAY = "birthday"; // public static final String DEATHDAY = "deathday"; // public static final String GENDER = "gender"; // public static final String HOMEPAGE = "homepage"; // public static final String ID = "id"; // public static final String NAME = "name"; // public static final String PLACE_OF_BIRTH = "place_of_birth"; // public static final String POPULARITY = "popularity"; // public static final String PROFILE_PATH = "profile_path"; // // public static final Uri CONTENT_URI = // BASE_CONTENT_URI.buildUpon().appendPath(PATH_PEOPLE).build(); // // static final String CONTENT_TYPE = // ContentResolver.CURSOR_DIR_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // static final String CONTENT_ITEM_TYPE = // ContentResolver.CURSOR_ITEM_BASE_TYPE + "/" + CONTENT_AUTHORITY + "/" + PATH_PEOPLE; // // static Uri buildPeopleUri(long id) { // return ContentUris.withAppendedId(CONTENT_URI, id); // } // // //content://work....../people/peopleId // public static Uri buildPeopleUriWithPeopleId(String peopleId) { // return CONTENT_URI.buildUpon().appendPath(peopleId).build(); // } // // public static Uri buildPersonUri() { // return CONTENT_URI.buildUpon().build(); // } // // public static String getIDFromUri(Uri uri) { // return uri.getPathSegments().get(1); // } // // } // // Path: app/src/main/java/work/technie/popularmovies/utils/AsyncResponse.java // public interface AsyncResponse { // void onFinish(boolean isData); // } // Path: app/src/main/java/work/technie/popularmovies/asyntask/FetchPeopleDetail.java import work.technie.popularmovies.data.MovieContract.People; import work.technie.popularmovies.utils.AsyncResponse; import android.content.ContentValues; import android.content.Context; import android.net.Uri; import android.os.AsyncTask; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import work.technie.popularmovies.BuildConfig; package work.technie.popularmovies.asyntask; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Created by anupam on 16/12/16. */ public class FetchPeopleDetail extends AsyncTask<String, Void, Void> { private final String LOG_TAG = FetchTVMovieTask.class.getSimpleName(); private final Context mContext; public AsyncResponse response = null; private boolean DEBUG = true; public FetchPeopleDetail(Context context) { mContext = context; } /** * Take the String representing the complete movie list in JSON Format and * pull out the data we need to construct the Strings needed for the wireframes. * <p> * Fortunately parsing is easy: constructor takes the JSON string and converts it * into an Object hierarchy for us. */ private void getMovieDataFromJson(String movieJsonStr) throws JSONException { try { JSONObject profileJson = new JSONObject(movieJsonStr); ContentValues[] cvArray = new ContentValues[1]; String adult; String biography; String birthday; String deathday; String gender; String homepage; String id; String name; String place_of_birth; String popularity; String profile_path;
adult = profileJson.getString(People.ADULT);
opticod/Opti-Movies
app/src/main/java/work/technie/popularmovies/adapter/GenreMovieAdapter.java
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_GENRE_NAME = 1;
import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_GENRE_NAME;
/* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 28/12/15. */ public class GenreMovieAdapter extends RecyclerView.Adapter<GenreMovieAdapter.ViewHolder> { private static final String LOG_TAG = GenreMovieAdapter.class.getSimpleName(); private final Cursor cursor; public GenreMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_genre_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { cursor.moveToPosition(position);
// Path: app/src/main/java/work/technie/popularmovies/Constants.java // public static final int COL_GENRE_NAME = 1; // Path: app/src/main/java/work/technie/popularmovies/adapter/GenreMovieAdapter.java import android.content.Context; import android.database.Cursor; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import work.technie.popularmovies.R; import static work.technie.popularmovies.Constants.COL_GENRE_NAME; /* * Copyright (C) 2017 Anupam Das * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package work.technie.popularmovies.adapter; /** * Created by anupam on 28/12/15. */ public class GenreMovieAdapter extends RecyclerView.Adapter<GenreMovieAdapter.ViewHolder> { private static final String LOG_TAG = GenreMovieAdapter.class.getSimpleName(); private final Cursor cursor; public GenreMovieAdapter(Cursor cursor) { this.cursor = cursor; } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(R.layout.list_genre_movie, parent, false); return new ViewHolder(view); } @Override public void onBindViewHolder(ViewHolder holder, int position) { cursor.moveToPosition(position);
final String genre = cursor.getString(COL_GENRE_NAME);
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushToDestinationStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationStep.java // public interface PushToDestinationStep extends PushStep { // // // // /** // * Targeting the audience of your push message using a <code>Filter</code>. // * Use the <code>Filters</code> factory to create filters. <br> // * <b>Example:</b><code>Filters.firstSession().less(4f).and(Filters.appVersion().greater("1.2.3"))</code> // * @param filter // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters">Notifications using filters</a> // */ // SendWithOptionsStep targetByFilter(Filter filter); // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param includeSegments a list of segments you want to include // * @return a SendToSegmentStep which allows you to exclude segments. // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendToSegmentStep targetBySegments(JsonArray includeSegments); // // /** // * Targeting the audience using OneSignal-playerIds. // * @param playerIds a list of playerIds // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-specific-devices">Notifications using playerIds</a> // */ // SendWithOptionsStep targetByPlayerIds(JsonArray playerIds); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // }
import io.github.jklingsporn.vertx.push.PushToDestinationStep; import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushToDestinationStep extends AbstractNoopPushStep implements PushToDestinationStep { private static final PushToDestinationStep INSTANCE = new NoopPushToDestinationStep(); public static PushToDestinationStep getInstance() { return INSTANCE; } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationStep.java // public interface PushToDestinationStep extends PushStep { // // // // /** // * Targeting the audience of your push message using a <code>Filter</code>. // * Use the <code>Filters</code> factory to create filters. <br> // * <b>Example:</b><code>Filters.firstSession().less(4f).and(Filters.appVersion().greater("1.2.3"))</code> // * @param filter // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters">Notifications using filters</a> // */ // SendWithOptionsStep targetByFilter(Filter filter); // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param includeSegments a list of segments you want to include // * @return a SendToSegmentStep which allows you to exclude segments. // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendToSegmentStep targetBySegments(JsonArray includeSegments); // // /** // * Targeting the audience using OneSignal-playerIds. // * @param playerIds a list of playerIds // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-specific-devices">Notifications using playerIds</a> // */ // SendWithOptionsStep targetByPlayerIds(JsonArray playerIds); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushToDestinationStep.java import io.github.jklingsporn.vertx.push.PushToDestinationStep; import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushToDestinationStep extends AbstractNoopPushStep implements PushToDestinationStep { private static final PushToDestinationStep INSTANCE = new NoopPushToDestinationStep(); public static PushToDestinationStep getInstance() { return INSTANCE; } @Override
public SendWithOptionsStep targetByFilter(Filter filter) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushToDestinationStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationStep.java // public interface PushToDestinationStep extends PushStep { // // // // /** // * Targeting the audience of your push message using a <code>Filter</code>. // * Use the <code>Filters</code> factory to create filters. <br> // * <b>Example:</b><code>Filters.firstSession().less(4f).and(Filters.appVersion().greater("1.2.3"))</code> // * @param filter // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters">Notifications using filters</a> // */ // SendWithOptionsStep targetByFilter(Filter filter); // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param includeSegments a list of segments you want to include // * @return a SendToSegmentStep which allows you to exclude segments. // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendToSegmentStep targetBySegments(JsonArray includeSegments); // // /** // * Targeting the audience using OneSignal-playerIds. // * @param playerIds a list of playerIds // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-specific-devices">Notifications using playerIds</a> // */ // SendWithOptionsStep targetByPlayerIds(JsonArray playerIds); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // }
import io.github.jklingsporn.vertx.push.PushToDestinationStep; import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushToDestinationStep extends AbstractNoopPushStep implements PushToDestinationStep { private static final PushToDestinationStep INSTANCE = new NoopPushToDestinationStep(); public static PushToDestinationStep getInstance() { return INSTANCE; } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationStep.java // public interface PushToDestinationStep extends PushStep { // // // // /** // * Targeting the audience of your push message using a <code>Filter</code>. // * Use the <code>Filters</code> factory to create filters. <br> // * <b>Example:</b><code>Filters.firstSession().less(4f).and(Filters.appVersion().greater("1.2.3"))</code> // * @param filter // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters">Notifications using filters</a> // */ // SendWithOptionsStep targetByFilter(Filter filter); // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param includeSegments a list of segments you want to include // * @return a SendToSegmentStep which allows you to exclude segments. // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendToSegmentStep targetBySegments(JsonArray includeSegments); // // /** // * Targeting the audience using OneSignal-playerIds. // * @param playerIds a list of playerIds // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-specific-devices">Notifications using playerIds</a> // */ // SendWithOptionsStep targetByPlayerIds(JsonArray playerIds); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushToDestinationStep.java import io.github.jklingsporn.vertx.push.PushToDestinationStep; import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushToDestinationStep extends AbstractNoopPushStep implements PushToDestinationStep { private static final PushToDestinationStep INSTANCE = new NoopPushToDestinationStep(); public static PushToDestinationStep getInstance() { return INSTANCE; } @Override
public SendWithOptionsStep targetByFilter(Filter filter) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushToDestinationStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationStep.java // public interface PushToDestinationStep extends PushStep { // // // // /** // * Targeting the audience of your push message using a <code>Filter</code>. // * Use the <code>Filters</code> factory to create filters. <br> // * <b>Example:</b><code>Filters.firstSession().less(4f).and(Filters.appVersion().greater("1.2.3"))</code> // * @param filter // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters">Notifications using filters</a> // */ // SendWithOptionsStep targetByFilter(Filter filter); // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param includeSegments a list of segments you want to include // * @return a SendToSegmentStep which allows you to exclude segments. // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendToSegmentStep targetBySegments(JsonArray includeSegments); // // /** // * Targeting the audience using OneSignal-playerIds. // * @param playerIds a list of playerIds // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-specific-devices">Notifications using playerIds</a> // */ // SendWithOptionsStep targetByPlayerIds(JsonArray playerIds); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // }
import io.github.jklingsporn.vertx.push.PushToDestinationStep; import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushToDestinationStep extends AbstractNoopPushStep implements PushToDestinationStep { private static final PushToDestinationStep INSTANCE = new NoopPushToDestinationStep(); public static PushToDestinationStep getInstance() { return INSTANCE; } @Override public SendWithOptionsStep targetByFilter(Filter filter) { return NoopSendWithOptionsStep.getInstance(); } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationStep.java // public interface PushToDestinationStep extends PushStep { // // // // /** // * Targeting the audience of your push message using a <code>Filter</code>. // * Use the <code>Filters</code> factory to create filters. <br> // * <b>Example:</b><code>Filters.firstSession().less(4f).and(Filters.appVersion().greater("1.2.3"))</code> // * @param filter // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-users-based-on-filters">Notifications using filters</a> // */ // SendWithOptionsStep targetByFilter(Filter filter); // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param includeSegments a list of segments you want to include // * @return a SendToSegmentStep which allows you to exclude segments. // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendToSegmentStep targetBySegments(JsonArray includeSegments); // // /** // * Targeting the audience using OneSignal-playerIds. // * @param playerIds a list of playerIds // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-specific-devices">Notifications using playerIds</a> // */ // SendWithOptionsStep targetByPlayerIds(JsonArray playerIds); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushToDestinationStep.java import io.github.jklingsporn.vertx.push.PushToDestinationStep; import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushToDestinationStep extends AbstractNoopPushStep implements PushToDestinationStep { private static final PushToDestinationStep INSTANCE = new NoopPushToDestinationStep(); public static PushToDestinationStep getInstance() { return INSTANCE; } @Override public SendWithOptionsStep targetByFilter(Filter filter) { return NoopSendWithOptionsStep.getInstance(); } @Override
public SendToSegmentStep targetBySegments(JsonArray includeSegments) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushClient.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/AddHeadersStep.java // public interface AddHeadersStep extends PushToDestinationStep{ // // /** // * Add <code>headings</code> option. // * @param headings something like {"en": "English Title", "es": "Spanish Title"} // * @return a PushToDestinationStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // PushToDestinationStep withHeadings(JsonObject headings); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/PushClient.java // public interface PushClient { // // /** // * @param vertx your Vertx instance // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(Vertx,PushClientOptions) instead // */ // static PushClient create(Vertx vertx, String appId, String restApiKey){ // return new OneSignalPushClient(vertx, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(HttpClient,PushClientOptions) instead // */ // static PushClient create(HttpClient httpClient, String appId, String restApiKey){ // return new OneSignalPushClient(httpClient, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(HttpClient httpClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(httpClient, pushClientOptions); // } // // /** // * @param vertx your Vertx instance // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(Vertx vertx, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(vertx, pushClientOptions); // } // // /** // * @param webClient the WebClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 2.1 // */ // static PushClient create(WebClient webClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(webClient, pushClientOptions); // } // // /** // * Creating a push request using the <code>template_id</code>. // * @param templateId the template that should be used. // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withTemplate(String templateId); // // /** // * Creating a push request using the <code>contents</code> option. // * @param contents something like {"en": "English Message", "es": "Spanish Message"} // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withContent(JsonObject contents); // // /** // * Send a raw push request and assembling parameters on your own. Warning: no plausibility checks are made. // * @return SendWithOptionsStep // */ // SendWithOptionsStep raw(); // // /** // * Cancel a notification of the given id. // * @param notificationId the id of the notification to cancel // * @param resultHandler the handler dealing with the result // * @since 2.2 // */ // void cancel(String notificationId, Handler<AsyncResult<JsonObject>> resultHandler); // // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // }
import io.github.jklingsporn.vertx.push.AddHeadersStep; import io.github.jklingsporn.vertx.push.PushClient; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushClient implements PushClient{ private static final PushClient INSTANCE = new NoopPushClient(); public static PushClient getInstance() { return INSTANCE; } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/AddHeadersStep.java // public interface AddHeadersStep extends PushToDestinationStep{ // // /** // * Add <code>headings</code> option. // * @param headings something like {"en": "English Title", "es": "Spanish Title"} // * @return a PushToDestinationStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // PushToDestinationStep withHeadings(JsonObject headings); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/PushClient.java // public interface PushClient { // // /** // * @param vertx your Vertx instance // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(Vertx,PushClientOptions) instead // */ // static PushClient create(Vertx vertx, String appId, String restApiKey){ // return new OneSignalPushClient(vertx, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(HttpClient,PushClientOptions) instead // */ // static PushClient create(HttpClient httpClient, String appId, String restApiKey){ // return new OneSignalPushClient(httpClient, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(HttpClient httpClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(httpClient, pushClientOptions); // } // // /** // * @param vertx your Vertx instance // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(Vertx vertx, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(vertx, pushClientOptions); // } // // /** // * @param webClient the WebClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 2.1 // */ // static PushClient create(WebClient webClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(webClient, pushClientOptions); // } // // /** // * Creating a push request using the <code>template_id</code>. // * @param templateId the template that should be used. // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withTemplate(String templateId); // // /** // * Creating a push request using the <code>contents</code> option. // * @param contents something like {"en": "English Message", "es": "Spanish Message"} // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withContent(JsonObject contents); // // /** // * Send a raw push request and assembling parameters on your own. Warning: no plausibility checks are made. // * @return SendWithOptionsStep // */ // SendWithOptionsStep raw(); // // /** // * Cancel a notification of the given id. // * @param notificationId the id of the notification to cancel // * @param resultHandler the handler dealing with the result // * @since 2.2 // */ // void cancel(String notificationId, Handler<AsyncResult<JsonObject>> resultHandler); // // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushClient.java import io.github.jklingsporn.vertx.push.AddHeadersStep; import io.github.jklingsporn.vertx.push.PushClient; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushClient implements PushClient{ private static final PushClient INSTANCE = new NoopPushClient(); public static PushClient getInstance() { return INSTANCE; } @Override
public AddHeadersStep withTemplate(String templateId) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushClient.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/AddHeadersStep.java // public interface AddHeadersStep extends PushToDestinationStep{ // // /** // * Add <code>headings</code> option. // * @param headings something like {"en": "English Title", "es": "Spanish Title"} // * @return a PushToDestinationStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // PushToDestinationStep withHeadings(JsonObject headings); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/PushClient.java // public interface PushClient { // // /** // * @param vertx your Vertx instance // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(Vertx,PushClientOptions) instead // */ // static PushClient create(Vertx vertx, String appId, String restApiKey){ // return new OneSignalPushClient(vertx, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(HttpClient,PushClientOptions) instead // */ // static PushClient create(HttpClient httpClient, String appId, String restApiKey){ // return new OneSignalPushClient(httpClient, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(HttpClient httpClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(httpClient, pushClientOptions); // } // // /** // * @param vertx your Vertx instance // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(Vertx vertx, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(vertx, pushClientOptions); // } // // /** // * @param webClient the WebClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 2.1 // */ // static PushClient create(WebClient webClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(webClient, pushClientOptions); // } // // /** // * Creating a push request using the <code>template_id</code>. // * @param templateId the template that should be used. // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withTemplate(String templateId); // // /** // * Creating a push request using the <code>contents</code> option. // * @param contents something like {"en": "English Message", "es": "Spanish Message"} // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withContent(JsonObject contents); // // /** // * Send a raw push request and assembling parameters on your own. Warning: no plausibility checks are made. // * @return SendWithOptionsStep // */ // SendWithOptionsStep raw(); // // /** // * Cancel a notification of the given id. // * @param notificationId the id of the notification to cancel // * @param resultHandler the handler dealing with the result // * @since 2.2 // */ // void cancel(String notificationId, Handler<AsyncResult<JsonObject>> resultHandler); // // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // }
import io.github.jklingsporn.vertx.push.AddHeadersStep; import io.github.jklingsporn.vertx.push.PushClient; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushClient implements PushClient{ private static final PushClient INSTANCE = new NoopPushClient(); public static PushClient getInstance() { return INSTANCE; } @Override public AddHeadersStep withTemplate(String templateId) { return NoopAddHeadersStep.getInstance(); } @Override public AddHeadersStep withContent(JsonObject contents) { return NoopAddHeadersStep.getInstance(); } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/AddHeadersStep.java // public interface AddHeadersStep extends PushToDestinationStep{ // // /** // * Add <code>headings</code> option. // * @param headings something like {"en": "English Title", "es": "Spanish Title"} // * @return a PushToDestinationStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // PushToDestinationStep withHeadings(JsonObject headings); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/PushClient.java // public interface PushClient { // // /** // * @param vertx your Vertx instance // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(Vertx,PushClientOptions) instead // */ // static PushClient create(Vertx vertx, String appId, String restApiKey){ // return new OneSignalPushClient(vertx, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(HttpClient,PushClientOptions) instead // */ // static PushClient create(HttpClient httpClient, String appId, String restApiKey){ // return new OneSignalPushClient(httpClient, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(HttpClient httpClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(httpClient, pushClientOptions); // } // // /** // * @param vertx your Vertx instance // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(Vertx vertx, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(vertx, pushClientOptions); // } // // /** // * @param webClient the WebClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 2.1 // */ // static PushClient create(WebClient webClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(webClient, pushClientOptions); // } // // /** // * Creating a push request using the <code>template_id</code>. // * @param templateId the template that should be used. // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withTemplate(String templateId); // // /** // * Creating a push request using the <code>contents</code> option. // * @param contents something like {"en": "English Message", "es": "Spanish Message"} // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withContent(JsonObject contents); // // /** // * Send a raw push request and assembling parameters on your own. Warning: no plausibility checks are made. // * @return SendWithOptionsStep // */ // SendWithOptionsStep raw(); // // /** // * Cancel a notification of the given id. // * @param notificationId the id of the notification to cancel // * @param resultHandler the handler dealing with the result // * @since 2.2 // */ // void cancel(String notificationId, Handler<AsyncResult<JsonObject>> resultHandler); // // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopPushClient.java import io.github.jklingsporn.vertx.push.AddHeadersStep; import io.github.jklingsporn.vertx.push.PushClient; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ public class NoopPushClient implements PushClient{ private static final PushClient INSTANCE = new NoopPushClient(); public static PushClient getInstance() { return INSTANCE; } @Override public AddHeadersStep withTemplate(String templateId) { return NoopAddHeadersStep.getInstance(); } @Override public AddHeadersStep withContent(JsonObject contents) { return NoopAddHeadersStep.getInstance(); } @Override
public SendWithOptionsStep raw() {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/filters/relations/ExistsRelation.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // }
import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl;
package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface ExistsRelation<X> extends Relation { /** * Checking if a value exists. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter exists(X value){
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // } // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/relations/ExistsRelation.java import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl; package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface ExistsRelation<X> extends Relation { /** * Checking if a value exists. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter exists(X value){
FilterImpl filter = new FilterImpl(getContext());
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationImpl.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // }
import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray;
package io.github.jklingsporn.vertx.push; /** * Created by jensklingsporn on 03.01.17. */ class PushToDestinationImpl extends AbstractPushStep implements PushToDestinationStep { public PushToDestinationImpl(PushMessageStep parent) { super(parent); } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/PushToDestinationImpl.java import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray; package io.github.jklingsporn.vertx.push; /** * Created by jensklingsporn on 03.01.17. */ class PushToDestinationImpl extends AbstractPushStep implements PushToDestinationStep { public PushToDestinationImpl(PushMessageStep parent) { super(parent); } @Override
public SendWithOptionsStep targetByFilter(Filter filter) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/filters/relations/NotEqualRelation.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // }
import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl;
package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface NotEqualRelation<X> extends Relation { /** * Compare the user's value against this value using a notEqual-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter notEqual(X value){
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // } // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/relations/NotEqualRelation.java import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl; package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface NotEqualRelation<X> extends Relation { /** * Compare the user's value against this value using a notEqual-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter notEqual(X value){
FilterImpl filter = new FilterImpl(getContext());
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopSendWithOptionsStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/SendOptions.java // public class SendOptions { // // public enum DelayedOption{ // TIMEZONE("timezone"), // LAST_ACTIVE("last-active"); // // private final String alias; // // DelayedOption(String alias) { // this.alias = alias; // } // } // // public enum Platform{ // AMAZON("isAdm"), // ANDROID("isAndroid"), // CHROME("isChrome"), // CHROME_APP("isChromeWeb"), // FIREFOX("isFirefox"), // IOS("isIos"), // SAFARI("isSafari"), // WEB("isAnyWeb"), // WINDOWS_PHONE("isWP"), // WINDOWS_PHONE_WNS("isWP_WNS"), // ; // private final String alias; // // Platform(String alias) { // this.alias = alias; // } // } // // private final JsonObject content; // // public SendOptions() { // this(new JsonObject()); // } // // public SendOptions(JsonObject content) { // this.content = content; // } // // public SendOptions setTTL(int ttl){ // return setCustom("ttl", ttl); // } // // public SendOptions setPriority(int priority){ // return setCustom("priority", priority); // } // // public SendOptions setDelayedOption(DelayedOption option){ // return setCustom("delayed_option",option.alias); // } // // public SendOptions setPlatform(Set<Platform> platforms){ // platforms.stream().forEach(p->content.put(p.alias,true)); // return this; // } // // public SendOptions setData(JsonObject data){ // return setCustom("data",data); // } // // public SendOptions setUrl(String url){ // return setCustom("url",url); // } // // public SendOptions setCustom(String key, Object value){ // content.put(key,value); // return this; // } // // JsonObject toJson(){ // return content; // } // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendStep.java // public interface SendStep extends PushStep{ // // /** // * // * @param resultHandler // */ // void sendNow(Handler<AsyncResult<JsonObject>> resultHandler); // // /** // * // * @param afterDate // * @param resultHandler // */ // void sendAfter(ZonedDateTime afterDate, Handler<AsyncResult<JsonObject>> resultHandler); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // }
import io.github.jklingsporn.vertx.push.SendOptions; import io.github.jklingsporn.vertx.push.SendStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import java.time.ZonedDateTime;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 03.01.17. */ class NoopSendWithOptionsStep extends AbstractNoopPushStep implements SendWithOptionsStep{ private static NoopSendWithOptionsStep INSTANCE; public static NoopSendWithOptionsStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopSendWithOptionsStep() : INSTANCE; } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/SendOptions.java // public class SendOptions { // // public enum DelayedOption{ // TIMEZONE("timezone"), // LAST_ACTIVE("last-active"); // // private final String alias; // // DelayedOption(String alias) { // this.alias = alias; // } // } // // public enum Platform{ // AMAZON("isAdm"), // ANDROID("isAndroid"), // CHROME("isChrome"), // CHROME_APP("isChromeWeb"), // FIREFOX("isFirefox"), // IOS("isIos"), // SAFARI("isSafari"), // WEB("isAnyWeb"), // WINDOWS_PHONE("isWP"), // WINDOWS_PHONE_WNS("isWP_WNS"), // ; // private final String alias; // // Platform(String alias) { // this.alias = alias; // } // } // // private final JsonObject content; // // public SendOptions() { // this(new JsonObject()); // } // // public SendOptions(JsonObject content) { // this.content = content; // } // // public SendOptions setTTL(int ttl){ // return setCustom("ttl", ttl); // } // // public SendOptions setPriority(int priority){ // return setCustom("priority", priority); // } // // public SendOptions setDelayedOption(DelayedOption option){ // return setCustom("delayed_option",option.alias); // } // // public SendOptions setPlatform(Set<Platform> platforms){ // platforms.stream().forEach(p->content.put(p.alias,true)); // return this; // } // // public SendOptions setData(JsonObject data){ // return setCustom("data",data); // } // // public SendOptions setUrl(String url){ // return setCustom("url",url); // } // // public SendOptions setCustom(String key, Object value){ // content.put(key,value); // return this; // } // // JsonObject toJson(){ // return content; // } // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendStep.java // public interface SendStep extends PushStep{ // // /** // * // * @param resultHandler // */ // void sendNow(Handler<AsyncResult<JsonObject>> resultHandler); // // /** // * // * @param afterDate // * @param resultHandler // */ // void sendAfter(ZonedDateTime afterDate, Handler<AsyncResult<JsonObject>> resultHandler); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopSendWithOptionsStep.java import io.github.jklingsporn.vertx.push.SendOptions; import io.github.jklingsporn.vertx.push.SendStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import java.time.ZonedDateTime; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 03.01.17. */ class NoopSendWithOptionsStep extends AbstractNoopPushStep implements SendWithOptionsStep{ private static NoopSendWithOptionsStep INSTANCE; public static NoopSendWithOptionsStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopSendWithOptionsStep() : INSTANCE; } @Override
public SendStep addOptions(SendOptions sendOptions) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopSendWithOptionsStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/SendOptions.java // public class SendOptions { // // public enum DelayedOption{ // TIMEZONE("timezone"), // LAST_ACTIVE("last-active"); // // private final String alias; // // DelayedOption(String alias) { // this.alias = alias; // } // } // // public enum Platform{ // AMAZON("isAdm"), // ANDROID("isAndroid"), // CHROME("isChrome"), // CHROME_APP("isChromeWeb"), // FIREFOX("isFirefox"), // IOS("isIos"), // SAFARI("isSafari"), // WEB("isAnyWeb"), // WINDOWS_PHONE("isWP"), // WINDOWS_PHONE_WNS("isWP_WNS"), // ; // private final String alias; // // Platform(String alias) { // this.alias = alias; // } // } // // private final JsonObject content; // // public SendOptions() { // this(new JsonObject()); // } // // public SendOptions(JsonObject content) { // this.content = content; // } // // public SendOptions setTTL(int ttl){ // return setCustom("ttl", ttl); // } // // public SendOptions setPriority(int priority){ // return setCustom("priority", priority); // } // // public SendOptions setDelayedOption(DelayedOption option){ // return setCustom("delayed_option",option.alias); // } // // public SendOptions setPlatform(Set<Platform> platforms){ // platforms.stream().forEach(p->content.put(p.alias,true)); // return this; // } // // public SendOptions setData(JsonObject data){ // return setCustom("data",data); // } // // public SendOptions setUrl(String url){ // return setCustom("url",url); // } // // public SendOptions setCustom(String key, Object value){ // content.put(key,value); // return this; // } // // JsonObject toJson(){ // return content; // } // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendStep.java // public interface SendStep extends PushStep{ // // /** // * // * @param resultHandler // */ // void sendNow(Handler<AsyncResult<JsonObject>> resultHandler); // // /** // * // * @param afterDate // * @param resultHandler // */ // void sendAfter(ZonedDateTime afterDate, Handler<AsyncResult<JsonObject>> resultHandler); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // }
import io.github.jklingsporn.vertx.push.SendOptions; import io.github.jklingsporn.vertx.push.SendStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import java.time.ZonedDateTime;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 03.01.17. */ class NoopSendWithOptionsStep extends AbstractNoopPushStep implements SendWithOptionsStep{ private static NoopSendWithOptionsStep INSTANCE; public static NoopSendWithOptionsStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopSendWithOptionsStep() : INSTANCE; } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/SendOptions.java // public class SendOptions { // // public enum DelayedOption{ // TIMEZONE("timezone"), // LAST_ACTIVE("last-active"); // // private final String alias; // // DelayedOption(String alias) { // this.alias = alias; // } // } // // public enum Platform{ // AMAZON("isAdm"), // ANDROID("isAndroid"), // CHROME("isChrome"), // CHROME_APP("isChromeWeb"), // FIREFOX("isFirefox"), // IOS("isIos"), // SAFARI("isSafari"), // WEB("isAnyWeb"), // WINDOWS_PHONE("isWP"), // WINDOWS_PHONE_WNS("isWP_WNS"), // ; // private final String alias; // // Platform(String alias) { // this.alias = alias; // } // } // // private final JsonObject content; // // public SendOptions() { // this(new JsonObject()); // } // // public SendOptions(JsonObject content) { // this.content = content; // } // // public SendOptions setTTL(int ttl){ // return setCustom("ttl", ttl); // } // // public SendOptions setPriority(int priority){ // return setCustom("priority", priority); // } // // public SendOptions setDelayedOption(DelayedOption option){ // return setCustom("delayed_option",option.alias); // } // // public SendOptions setPlatform(Set<Platform> platforms){ // platforms.stream().forEach(p->content.put(p.alias,true)); // return this; // } // // public SendOptions setData(JsonObject data){ // return setCustom("data",data); // } // // public SendOptions setUrl(String url){ // return setCustom("url",url); // } // // public SendOptions setCustom(String key, Object value){ // content.put(key,value); // return this; // } // // JsonObject toJson(){ // return content; // } // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendStep.java // public interface SendStep extends PushStep{ // // /** // * // * @param resultHandler // */ // void sendNow(Handler<AsyncResult<JsonObject>> resultHandler); // // /** // * // * @param afterDate // * @param resultHandler // */ // void sendAfter(ZonedDateTime afterDate, Handler<AsyncResult<JsonObject>> resultHandler); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopSendWithOptionsStep.java import io.github.jklingsporn.vertx.push.SendOptions; import io.github.jklingsporn.vertx.push.SendStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.AsyncResult; import io.vertx.core.Future; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import java.time.ZonedDateTime; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 03.01.17. */ class NoopSendWithOptionsStep extends AbstractNoopPushStep implements SendWithOptionsStep{ private static NoopSendWithOptionsStep INSTANCE; public static NoopSendWithOptionsStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopSendWithOptionsStep() : INSTANCE; } @Override
public SendStep addOptions(SendOptions sendOptions) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/AbstractNoopPushStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushClient.java // public interface PushClient { // // /** // * @param vertx your Vertx instance // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(Vertx,PushClientOptions) instead // */ // static PushClient create(Vertx vertx, String appId, String restApiKey){ // return new OneSignalPushClient(vertx, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(HttpClient,PushClientOptions) instead // */ // static PushClient create(HttpClient httpClient, String appId, String restApiKey){ // return new OneSignalPushClient(httpClient, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(HttpClient httpClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(httpClient, pushClientOptions); // } // // /** // * @param vertx your Vertx instance // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(Vertx vertx, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(vertx, pushClientOptions); // } // // /** // * @param webClient the WebClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 2.1 // */ // static PushClient create(WebClient webClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(webClient, pushClientOptions); // } // // /** // * Creating a push request using the <code>template_id</code>. // * @param templateId the template that should be used. // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withTemplate(String templateId); // // /** // * Creating a push request using the <code>contents</code> option. // * @param contents something like {"en": "English Message", "es": "Spanish Message"} // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withContent(JsonObject contents); // // /** // * Send a raw push request and assembling parameters on your own. Warning: no plausibility checks are made. // * @return SendWithOptionsStep // */ // SendWithOptionsStep raw(); // // /** // * Cancel a notification of the given id. // * @param notificationId the id of the notification to cancel // * @param resultHandler the handler dealing with the result // * @since 2.2 // */ // void cancel(String notificationId, Handler<AsyncResult<JsonObject>> resultHandler); // // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/PushStep.java // public interface PushStep { // // JsonObject container(); // // PushClient client(); // }
import io.github.jklingsporn.vertx.push.PushClient; import io.github.jklingsporn.vertx.push.PushStep; import io.vertx.core.json.JsonObject;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ abstract class AbstractNoopPushStep implements PushStep{ private static final JsonObject NOOP_CONTAINER = new JsonObject(); @Override public JsonObject container() { return NOOP_CONTAINER; } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/PushClient.java // public interface PushClient { // // /** // * @param vertx your Vertx instance // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(Vertx,PushClientOptions) instead // */ // static PushClient create(Vertx vertx, String appId, String restApiKey){ // return new OneSignalPushClient(vertx, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param appId your OneSignal AppId // * @param restApiKey your OneSignal API-Key // * @return a PushClient // * @deprecated Consider using PushClient#create(HttpClient,PushClientOptions) instead // */ // static PushClient create(HttpClient httpClient, String appId, String restApiKey){ // return new OneSignalPushClient(httpClient, new PushClientOptions().setAppId(appId).setRestApiKey(restApiKey)); // } // // /** // * @param httpClient the HttpClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(HttpClient httpClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(httpClient, pushClientOptions); // } // // /** // * @param vertx your Vertx instance // * @param pushClientOptions the options // * @return a PushClient // * @since 1.7 // */ // static PushClient create(Vertx vertx, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(vertx, pushClientOptions); // } // // /** // * @param webClient the WebClient to use for calling the OneSignal-API. // * @param pushClientOptions the options // * @return a PushClient // * @since 2.1 // */ // static PushClient create(WebClient webClient, PushClientOptions pushClientOptions){ // return new OneSignalPushClient(webClient, pushClientOptions); // } // // /** // * Creating a push request using the <code>template_id</code>. // * @param templateId the template that should be used. // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withTemplate(String templateId); // // /** // * Creating a push request using the <code>contents</code> option. // * @param contents something like {"en": "English Message", "es": "Spanish Message"} // * @return a AddHeadersStep // * @see <a href="https://documentation.onesignal.com/reference#section-content-language">Create notification</a> // */ // AddHeadersStep withContent(JsonObject contents); // // /** // * Send a raw push request and assembling parameters on your own. Warning: no plausibility checks are made. // * @return SendWithOptionsStep // */ // SendWithOptionsStep raw(); // // /** // * Cancel a notification of the given id. // * @param notificationId the id of the notification to cancel // * @param resultHandler the handler dealing with the result // * @since 2.2 // */ // void cancel(String notificationId, Handler<AsyncResult<JsonObject>> resultHandler); // // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/PushStep.java // public interface PushStep { // // JsonObject container(); // // PushClient client(); // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/AbstractNoopPushStep.java import io.github.jklingsporn.vertx.push.PushClient; import io.github.jklingsporn.vertx.push.PushStep; import io.vertx.core.json.JsonObject; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ abstract class AbstractNoopPushStep implements PushStep{ private static final JsonObject NOOP_CONTAINER = new JsonObject(); @Override public JsonObject container() { return NOOP_CONTAINER; } @Override
public PushClient client() {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/filters/relations/GreaterRelation.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // }
import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl;
package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface GreaterRelation<X> extends Relation { /** * Compare the user's value against this value using a greater-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter greater(X value){
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // } // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/relations/GreaterRelation.java import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl; package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface GreaterRelation<X> extends Relation { /** * Compare the user's value against this value using a greater-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter greater(X value){
FilterImpl filter = new FilterImpl(getContext());
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/filters/relations/NotExistsRelation.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // }
import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl;
package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface NotExistsRelation<X> extends Relation { /** * Checking if a value not exists. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter notExists(X value){
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // } // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/relations/NotExistsRelation.java import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl; package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface NotExistsRelation<X> extends Relation { /** * Checking if a value not exists. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter notExists(X value){
FilterImpl filter = new FilterImpl(getContext());
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/filters/relations/LessRelation.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // }
import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl;
package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface LessRelation<X> extends Relation { /** * Compare the user's value against this value using a less-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter less(X value){
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // } // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/relations/LessRelation.java import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl; package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface LessRelation<X> extends Relation { /** * Compare the user's value against this value using a less-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter less(X value){
FilterImpl filter = new FilterImpl(getContext());
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopSendToSegmentStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // }
import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.json.JsonArray;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 04.01.17. */ class NoopSendToSegmentStep extends NoopSendWithOptionsStep implements SendToSegmentStep { private static NoopSendToSegmentStep INSTANCE; public static NoopSendToSegmentStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopSendToSegmentStep() : INSTANCE; } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/SendToSegmentStep.java // public interface SendToSegmentStep extends SendWithOptionsStep { // // /** // * Targeting the audience using segments (which can be set up in the OneSignal dashboard). // * @param excludeSegments a list of segments you want to <b>exclude</b> // * @return a SendWithOptionsStep // * @see <a href="https://documentation.onesignal.com/reference#section-send-to-segments">Notifications using segments</a> // */ // SendWithOptionsStep exclude(JsonArray excludeSegments); // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/SendWithOptionsStep.java // public interface SendWithOptionsStep extends SendStep{ // // /** // * Specify further options. Some common options are directly included in the <code>SendOptions</code> class others // * can be manually added using the <code>SendOptions#addCustom</code>-method.<br> // * <b>Example:</b> <code>new SendOptions().setPlatform(EnumSet.of(SendOptions.Platform.AMAZON, SendOptions.Platform.ANDROID)).setCustom("foo","bar")</code> // * @param sendOptions // * @return a SendStep // * @see <a href="https://documentation.onesignal.com/reference#section-example-code-create-notification">OneSignal documentation</a> // */ // SendStep addOptions(SendOptions sendOptions); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopSendToSegmentStep.java import io.github.jklingsporn.vertx.push.SendToSegmentStep; import io.github.jklingsporn.vertx.push.SendWithOptionsStep; import io.vertx.core.json.JsonArray; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 04.01.17. */ class NoopSendToSegmentStep extends NoopSendWithOptionsStep implements SendToSegmentStep { private static NoopSendToSegmentStep INSTANCE; public static NoopSendToSegmentStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopSendToSegmentStep() : INSTANCE; } @Override
public SendWithOptionsStep exclude(JsonArray excludeSegments) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/noop/NoopAddHeadersStep.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // }
import io.github.jklingsporn.vertx.push.*; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject;
package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ class NoopAddHeadersStep extends AbstractNoopPushStep implements AddHeadersStep{ private static AddHeadersStep INSTANCE; public static AddHeadersStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopAddHeadersStep() : INSTANCE; } @Override public PushToDestinationStep withHeadings(JsonObject headings) { return NoopPushToDestinationStep.getInstance(); } @Override
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // Path: src/main/java/io/github/jklingsporn/vertx/push/noop/NoopAddHeadersStep.java import io.github.jklingsporn.vertx.push.*; import io.github.jklingsporn.vertx.push.filters.Filter; import io.vertx.core.json.JsonArray; import io.vertx.core.json.JsonObject; package io.github.jklingsporn.vertx.push.noop; /** * Created by jensklingsporn on 06.04.17. */ class NoopAddHeadersStep extends AbstractNoopPushStep implements AddHeadersStep{ private static AddHeadersStep INSTANCE; public static AddHeadersStep getInstance() { return INSTANCE == null ? INSTANCE = new NoopAddHeadersStep() : INSTANCE; } @Override public PushToDestinationStep withHeadings(JsonObject headings) { return NoopPushToDestinationStep.getInstance(); } @Override
public SendWithOptionsStep targetByFilter(Filter filter) {
jklingsporn/vertx-push-onesignal
src/main/java/io/github/jklingsporn/vertx/push/filters/relations/EqualRelation.java
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // }
import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl;
package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface EqualRelation<X> extends Relation { /** * Compare the user's value against this value using a equal-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter equal(X value){
// Path: src/main/java/io/github/jklingsporn/vertx/push/filters/Filter.java // public interface Filter { // // Filter and(Filter other); // // Filter or(Filter other); // // JsonArray asJsonArray(); // // JsonObject content(); // // } // // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/FilterImpl.java // public class FilterImpl implements Filter{ // // private static final JsonObject OR = new JsonObject().put("operator", "OR"); // private final JsonArray contents = new JsonArray(); // private final JsonObject content = new JsonObject(); // // public FilterImpl(String field) { // content().put("field",field); // contents.add(content); // } // // @Override // public Filter and(Filter other) { // contents.add(other.content()); // return this; // } // // @Override // public Filter or(Filter other) { // contents.add(OR).add(other.content()); // return this; // } // // @Override // public JsonArray asJsonArray() { // return contents; // } // // @Override // public JsonObject content() { // return content; // } // } // Path: src/main/java/io/github/jklingsporn/vertx/push/filters/relations/EqualRelation.java import io.github.jklingsporn.vertx.push.filters.Filter; import io.github.jklingsporn.vertx.push.filters.FilterImpl; package io.github.jklingsporn.vertx.push.filters.relations; /** * Created by jensklingsporn on 04.01.17. */ public interface EqualRelation<X> extends Relation { /** * Compare the user's value against this value using a equal-relation. * The unit of the value depends on the chosen <code>Filter</code>. * @param value * @return a Filter */ default Filter equal(X value){
FilterImpl filter = new FilterImpl(getContext());
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolylineManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolylineClickListener { // // void onPolylineClick(Polyline polyline); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polyline.java // public interface Polyline { // // int getColor(); // // <T> T getData(); // // Cap getEndCap(); // // @Deprecated // String getId(); // // int getJointType(); // // List<PatternItem> getPattern(); // // List<LatLng> getPoints(); // // Cap getStartCap(); // // Object getTag(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setColor(int color); // // void setData(Object data); // // void setEndCap(Cap endCap); // // void setGeodesic(boolean geodesic); // // void setJointType(int jointType); // // void setPattern(List<PatternItem> pattern); // // void setPoints(List<LatLng> points); // // void setStartCap(Cap startCap); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setWidth(float width); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolylineOptions.java // public class PolylineOptions { // // public final com.google.android.gms.maps.model.PolylineOptions real = new com.google.android.gms.maps.model.PolylineOptions(); // private Object data; // // public PolylineOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolylineOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolylineOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolylineOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolylineOptions color(int color) { // real.color(color); // return this; // } // // public PolylineOptions data(Object data) { // this.data = data; // return this; // } // // public PolylineOptions endCap(Cap cap) { // real.endCap(cap); // return this; // } // // public PolylineOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public int getColor() { // return real.getColor(); // } // // public Object getData() { // return data; // } // // public Cap getEndCap() { // return real.getEndCap(); // } // // public int getJointType() { // return real.getJointType(); // } // // public List<PatternItem> getPattern() { // return real.getPattern(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public Cap getStartCap() { // return real.getStartCap(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolylineOptions jointType(int type) { // real.jointType(type); // return this; // } // // public PolylineOptions pattern(List<PatternItem> pattern) { // real.pattern(pattern); // return this; // } // // public PolylineOptions startCap(Cap cap) { // real.startCap(cap); // return this; // } // // public PolylineOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolylineOptions width(float width) { // real.width(width); // return this; // } // // public PolylineOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.GoogleMap.OnPolylineClickListener; import com.androidmapsextensions.Polyline; import com.androidmapsextensions.PolylineOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolylineManager { private final IGoogleMap factory;
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolylineClickListener { // // void onPolylineClick(Polyline polyline); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polyline.java // public interface Polyline { // // int getColor(); // // <T> T getData(); // // Cap getEndCap(); // // @Deprecated // String getId(); // // int getJointType(); // // List<PatternItem> getPattern(); // // List<LatLng> getPoints(); // // Cap getStartCap(); // // Object getTag(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setColor(int color); // // void setData(Object data); // // void setEndCap(Cap endCap); // // void setGeodesic(boolean geodesic); // // void setJointType(int jointType); // // void setPattern(List<PatternItem> pattern); // // void setPoints(List<LatLng> points); // // void setStartCap(Cap startCap); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setWidth(float width); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolylineOptions.java // public class PolylineOptions { // // public final com.google.android.gms.maps.model.PolylineOptions real = new com.google.android.gms.maps.model.PolylineOptions(); // private Object data; // // public PolylineOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolylineOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolylineOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolylineOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolylineOptions color(int color) { // real.color(color); // return this; // } // // public PolylineOptions data(Object data) { // this.data = data; // return this; // } // // public PolylineOptions endCap(Cap cap) { // real.endCap(cap); // return this; // } // // public PolylineOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public int getColor() { // return real.getColor(); // } // // public Object getData() { // return data; // } // // public Cap getEndCap() { // return real.getEndCap(); // } // // public int getJointType() { // return real.getJointType(); // } // // public List<PatternItem> getPattern() { // return real.getPattern(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public Cap getStartCap() { // return real.getStartCap(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolylineOptions jointType(int type) { // real.jointType(type); // return this; // } // // public PolylineOptions pattern(List<PatternItem> pattern) { // real.pattern(pattern); // return this; // } // // public PolylineOptions startCap(Cap cap) { // real.startCap(cap); // return this; // } // // public PolylineOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolylineOptions width(float width) { // real.width(width); // return this; // } // // public PolylineOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolylineManager.java import com.androidmapsextensions.GoogleMap.OnPolylineClickListener; import com.androidmapsextensions.Polyline; import com.androidmapsextensions.PolylineOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolylineManager { private final IGoogleMap factory;
private final Map<com.google.android.gms.maps.model.Polyline, Polyline> polylines;
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolylineManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolylineClickListener { // // void onPolylineClick(Polyline polyline); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polyline.java // public interface Polyline { // // int getColor(); // // <T> T getData(); // // Cap getEndCap(); // // @Deprecated // String getId(); // // int getJointType(); // // List<PatternItem> getPattern(); // // List<LatLng> getPoints(); // // Cap getStartCap(); // // Object getTag(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setColor(int color); // // void setData(Object data); // // void setEndCap(Cap endCap); // // void setGeodesic(boolean geodesic); // // void setJointType(int jointType); // // void setPattern(List<PatternItem> pattern); // // void setPoints(List<LatLng> points); // // void setStartCap(Cap startCap); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setWidth(float width); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolylineOptions.java // public class PolylineOptions { // // public final com.google.android.gms.maps.model.PolylineOptions real = new com.google.android.gms.maps.model.PolylineOptions(); // private Object data; // // public PolylineOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolylineOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolylineOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolylineOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolylineOptions color(int color) { // real.color(color); // return this; // } // // public PolylineOptions data(Object data) { // this.data = data; // return this; // } // // public PolylineOptions endCap(Cap cap) { // real.endCap(cap); // return this; // } // // public PolylineOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public int getColor() { // return real.getColor(); // } // // public Object getData() { // return data; // } // // public Cap getEndCap() { // return real.getEndCap(); // } // // public int getJointType() { // return real.getJointType(); // } // // public List<PatternItem> getPattern() { // return real.getPattern(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public Cap getStartCap() { // return real.getStartCap(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolylineOptions jointType(int type) { // real.jointType(type); // return this; // } // // public PolylineOptions pattern(List<PatternItem> pattern) { // real.pattern(pattern); // return this; // } // // public PolylineOptions startCap(Cap cap) { // real.startCap(cap); // return this; // } // // public PolylineOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolylineOptions width(float width) { // real.width(width); // return this; // } // // public PolylineOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.GoogleMap.OnPolylineClickListener; import com.androidmapsextensions.Polyline; import com.androidmapsextensions.PolylineOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolylineManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Polyline, Polyline> polylines; public PolylineManager(IGoogleMap factory) { this.factory = factory; this.polylines = new HashMap<>(); }
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolylineClickListener { // // void onPolylineClick(Polyline polyline); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polyline.java // public interface Polyline { // // int getColor(); // // <T> T getData(); // // Cap getEndCap(); // // @Deprecated // String getId(); // // int getJointType(); // // List<PatternItem> getPattern(); // // List<LatLng> getPoints(); // // Cap getStartCap(); // // Object getTag(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setColor(int color); // // void setData(Object data); // // void setEndCap(Cap endCap); // // void setGeodesic(boolean geodesic); // // void setJointType(int jointType); // // void setPattern(List<PatternItem> pattern); // // void setPoints(List<LatLng> points); // // void setStartCap(Cap startCap); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setWidth(float width); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolylineOptions.java // public class PolylineOptions { // // public final com.google.android.gms.maps.model.PolylineOptions real = new com.google.android.gms.maps.model.PolylineOptions(); // private Object data; // // public PolylineOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolylineOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolylineOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolylineOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolylineOptions color(int color) { // real.color(color); // return this; // } // // public PolylineOptions data(Object data) { // this.data = data; // return this; // } // // public PolylineOptions endCap(Cap cap) { // real.endCap(cap); // return this; // } // // public PolylineOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public int getColor() { // return real.getColor(); // } // // public Object getData() { // return data; // } // // public Cap getEndCap() { // return real.getEndCap(); // } // // public int getJointType() { // return real.getJointType(); // } // // public List<PatternItem> getPattern() { // return real.getPattern(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public Cap getStartCap() { // return real.getStartCap(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolylineOptions jointType(int type) { // real.jointType(type); // return this; // } // // public PolylineOptions pattern(List<PatternItem> pattern) { // real.pattern(pattern); // return this; // } // // public PolylineOptions startCap(Cap cap) { // real.startCap(cap); // return this; // } // // public PolylineOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolylineOptions width(float width) { // real.width(width); // return this; // } // // public PolylineOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolylineManager.java import com.androidmapsextensions.GoogleMap.OnPolylineClickListener; import com.androidmapsextensions.Polyline; import com.androidmapsextensions.PolylineOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolylineManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Polyline, Polyline> polylines; public PolylineManager(IGoogleMap factory) { this.factory = factory; this.polylines = new HashMap<>(); }
public Polyline addPolyline(PolylineOptions polylineOptions) {
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/GroundOverlayManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnGroundOverlayClickListener { // // void onGroundOverlayClick(GroundOverlay groundOverlay); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlay.java // public interface GroundOverlay { // // float getBearing(); // // LatLngBounds getBounds(); // // <T> T getData(); // // float getHeight(); // // @Deprecated // String getId(); // // LatLng getPosition(); // // Object getTag(); // // float getTransparency(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setBearing(float bearing); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setDimensions(float width, float height); // // void setDimensions(float width); // // void setImage(BitmapDescriptor image); // // void setPosition(LatLng position); // // void setPositionFromBounds(LatLngBounds bounds); // // void setTag(Object tag); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlayOptions.java // public class GroundOverlayOptions { // // public final com.google.android.gms.maps.model.GroundOverlayOptions real = new com.google.android.gms.maps.model.GroundOverlayOptions(); // private Object data; // // public GroundOverlayOptions anchor(float u, float v) { // real.anchor(u, v); // return this; // } // // public GroundOverlayOptions bearing(float bearing) { // real.bearing(bearing); // return this; // } // // public GroundOverlayOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public GroundOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public float getAnchorU() { // return real.getAnchorU(); // } // // public float getAnchorV() { // return real.getAnchorV(); // } // // public float getBearing() { // return real.getBearing(); // } // // public LatLngBounds getBounds() { // return real.getBounds(); // } // // public Object getData() { // return data; // } // // public float getHeight() { // return real.getHeight(); // } // // public BitmapDescriptor getImage() { // return real.getImage(); // } // // public LatLng getLocation() { // return real.getLocation(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public GroundOverlayOptions image(BitmapDescriptor image) { // real.image(image); // return this; // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public GroundOverlayOptions position(LatLng location, float width) { // real.position(location, width); // return this; // } // // public GroundOverlayOptions position(LatLng location, float width, float height) { // real.position(location, width, height); // return this; // } // // public GroundOverlayOptions positionFromBounds(LatLngBounds bounds) { // real.positionFromBounds(bounds); // return this; // } // // public GroundOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public GroundOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public GroundOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.GoogleMap.OnGroundOverlayClickListener; import com.androidmapsextensions.GroundOverlay; import com.androidmapsextensions.GroundOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class GroundOverlayManager { private final IGoogleMap factory;
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnGroundOverlayClickListener { // // void onGroundOverlayClick(GroundOverlay groundOverlay); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlay.java // public interface GroundOverlay { // // float getBearing(); // // LatLngBounds getBounds(); // // <T> T getData(); // // float getHeight(); // // @Deprecated // String getId(); // // LatLng getPosition(); // // Object getTag(); // // float getTransparency(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setBearing(float bearing); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setDimensions(float width, float height); // // void setDimensions(float width); // // void setImage(BitmapDescriptor image); // // void setPosition(LatLng position); // // void setPositionFromBounds(LatLngBounds bounds); // // void setTag(Object tag); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlayOptions.java // public class GroundOverlayOptions { // // public final com.google.android.gms.maps.model.GroundOverlayOptions real = new com.google.android.gms.maps.model.GroundOverlayOptions(); // private Object data; // // public GroundOverlayOptions anchor(float u, float v) { // real.anchor(u, v); // return this; // } // // public GroundOverlayOptions bearing(float bearing) { // real.bearing(bearing); // return this; // } // // public GroundOverlayOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public GroundOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public float getAnchorU() { // return real.getAnchorU(); // } // // public float getAnchorV() { // return real.getAnchorV(); // } // // public float getBearing() { // return real.getBearing(); // } // // public LatLngBounds getBounds() { // return real.getBounds(); // } // // public Object getData() { // return data; // } // // public float getHeight() { // return real.getHeight(); // } // // public BitmapDescriptor getImage() { // return real.getImage(); // } // // public LatLng getLocation() { // return real.getLocation(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public GroundOverlayOptions image(BitmapDescriptor image) { // real.image(image); // return this; // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public GroundOverlayOptions position(LatLng location, float width) { // real.position(location, width); // return this; // } // // public GroundOverlayOptions position(LatLng location, float width, float height) { // real.position(location, width, height); // return this; // } // // public GroundOverlayOptions positionFromBounds(LatLngBounds bounds) { // real.positionFromBounds(bounds); // return this; // } // // public GroundOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public GroundOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public GroundOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/GroundOverlayManager.java import com.androidmapsextensions.GoogleMap.OnGroundOverlayClickListener; import com.androidmapsextensions.GroundOverlay; import com.androidmapsextensions.GroundOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class GroundOverlayManager { private final IGoogleMap factory;
private final Map<com.google.android.gms.maps.model.GroundOverlay, GroundOverlay> groundOverlays;
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/GroundOverlayManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnGroundOverlayClickListener { // // void onGroundOverlayClick(GroundOverlay groundOverlay); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlay.java // public interface GroundOverlay { // // float getBearing(); // // LatLngBounds getBounds(); // // <T> T getData(); // // float getHeight(); // // @Deprecated // String getId(); // // LatLng getPosition(); // // Object getTag(); // // float getTransparency(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setBearing(float bearing); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setDimensions(float width, float height); // // void setDimensions(float width); // // void setImage(BitmapDescriptor image); // // void setPosition(LatLng position); // // void setPositionFromBounds(LatLngBounds bounds); // // void setTag(Object tag); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlayOptions.java // public class GroundOverlayOptions { // // public final com.google.android.gms.maps.model.GroundOverlayOptions real = new com.google.android.gms.maps.model.GroundOverlayOptions(); // private Object data; // // public GroundOverlayOptions anchor(float u, float v) { // real.anchor(u, v); // return this; // } // // public GroundOverlayOptions bearing(float bearing) { // real.bearing(bearing); // return this; // } // // public GroundOverlayOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public GroundOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public float getAnchorU() { // return real.getAnchorU(); // } // // public float getAnchorV() { // return real.getAnchorV(); // } // // public float getBearing() { // return real.getBearing(); // } // // public LatLngBounds getBounds() { // return real.getBounds(); // } // // public Object getData() { // return data; // } // // public float getHeight() { // return real.getHeight(); // } // // public BitmapDescriptor getImage() { // return real.getImage(); // } // // public LatLng getLocation() { // return real.getLocation(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public GroundOverlayOptions image(BitmapDescriptor image) { // real.image(image); // return this; // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public GroundOverlayOptions position(LatLng location, float width) { // real.position(location, width); // return this; // } // // public GroundOverlayOptions position(LatLng location, float width, float height) { // real.position(location, width, height); // return this; // } // // public GroundOverlayOptions positionFromBounds(LatLngBounds bounds) { // real.positionFromBounds(bounds); // return this; // } // // public GroundOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public GroundOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public GroundOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.GoogleMap.OnGroundOverlayClickListener; import com.androidmapsextensions.GroundOverlay; import com.androidmapsextensions.GroundOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class GroundOverlayManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.GroundOverlay, GroundOverlay> groundOverlays; public GroundOverlayManager(IGoogleMap factory) { this.factory = factory; this.groundOverlays = new HashMap<>(); }
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnGroundOverlayClickListener { // // void onGroundOverlayClick(GroundOverlay groundOverlay); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlay.java // public interface GroundOverlay { // // float getBearing(); // // LatLngBounds getBounds(); // // <T> T getData(); // // float getHeight(); // // @Deprecated // String getId(); // // LatLng getPosition(); // // Object getTag(); // // float getTransparency(); // // float getWidth(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setBearing(float bearing); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setDimensions(float width, float height); // // void setDimensions(float width); // // void setImage(BitmapDescriptor image); // // void setPosition(LatLng position); // // void setPositionFromBounds(LatLngBounds bounds); // // void setTag(Object tag); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GroundOverlayOptions.java // public class GroundOverlayOptions { // // public final com.google.android.gms.maps.model.GroundOverlayOptions real = new com.google.android.gms.maps.model.GroundOverlayOptions(); // private Object data; // // public GroundOverlayOptions anchor(float u, float v) { // real.anchor(u, v); // return this; // } // // public GroundOverlayOptions bearing(float bearing) { // real.bearing(bearing); // return this; // } // // public GroundOverlayOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public GroundOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public float getAnchorU() { // return real.getAnchorU(); // } // // public float getAnchorV() { // return real.getAnchorV(); // } // // public float getBearing() { // return real.getBearing(); // } // // public LatLngBounds getBounds() { // return real.getBounds(); // } // // public Object getData() { // return data; // } // // public float getHeight() { // return real.getHeight(); // } // // public BitmapDescriptor getImage() { // return real.getImage(); // } // // public LatLng getLocation() { // return real.getLocation(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getWidth() { // return real.getWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public GroundOverlayOptions image(BitmapDescriptor image) { // real.image(image); // return this; // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public GroundOverlayOptions position(LatLng location, float width) { // real.position(location, width); // return this; // } // // public GroundOverlayOptions position(LatLng location, float width, float height) { // real.position(location, width, height); // return this; // } // // public GroundOverlayOptions positionFromBounds(LatLngBounds bounds) { // real.positionFromBounds(bounds); // return this; // } // // public GroundOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public GroundOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public GroundOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/GroundOverlayManager.java import com.androidmapsextensions.GoogleMap.OnGroundOverlayClickListener; import com.androidmapsextensions.GroundOverlay; import com.androidmapsextensions.GroundOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class GroundOverlayManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.GroundOverlay, GroundOverlay> groundOverlays; public GroundOverlayManager(IGoogleMap factory) { this.factory = factory; this.groundOverlays = new HashMap<>(); }
public GroundOverlay addGroundOverlay(GroundOverlayOptions groundOverlayOptions) {
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/fragments/WebFragment.java
// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java // public class Constants { // public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB // public static final int TWEETS_PER_PAGE = 50; // // public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message"; // public static final String FIREBASE_CONFIG_WEB_URL = "web_url"; // public static final String FIREBASE_CONFIG_API_URL = "api_url"; // public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html"; // // public static final String TWITTER_CONSUMER_KEY = "XXXXXX"; // public static final String TWITTER_CONSUMER_SECRET = "XXXXXX"; // }
import android.annotation.SuppressLint; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.net.http.SslError; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.SslErrorHandler; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.referendum.uoctubre.R; import com.referendum.uoctubre.main.Constants; import im.delight.android.webview.AdvancedWebView;
package com.referendum.uoctubre.fragments; public class WebFragment extends BaseFragment implements AdvancedWebView.Listener { public static final String TAG = "web_fragment"; public static WebFragment newInstance() { Bundle args = new Bundle(); WebFragment fragment = new WebFragment(); fragment.setArguments(args); return fragment; } private AdvancedWebView mWebView; private View loadingLayout; private View errorLayout; @SuppressLint("SetJavaScriptEnabled") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_web, container, false); mWebView = view.findViewById(R.id.webview); loadingLayout = view.findViewById(R.id.loading_layout); errorLayout = view.findViewById(R.id.error_layout); errorLayout.findViewById(R.id.error_retry_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { errorLayout.setVisibility(View.GONE); loadingLayout.setVisibility(View.VISIBLE); mWebView.setVisibility(View.VISIBLE); mWebView.loadUrl("about:blank"); //Allow to change URL via Firebase FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java // public class Constants { // public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB // public static final int TWEETS_PER_PAGE = 50; // // public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message"; // public static final String FIREBASE_CONFIG_WEB_URL = "web_url"; // public static final String FIREBASE_CONFIG_API_URL = "api_url"; // public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html"; // // public static final String TWITTER_CONSUMER_KEY = "XXXXXX"; // public static final String TWITTER_CONSUMER_SECRET = "XXXXXX"; // } // Path: app/src/main/java/com/referendum/uoctubre/fragments/WebFragment.java import android.annotation.SuppressLint; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; import android.net.http.SslError; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.SslErrorHandler; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.referendum.uoctubre.R; import com.referendum.uoctubre.main.Constants; import im.delight.android.webview.AdvancedWebView; package com.referendum.uoctubre.fragments; public class WebFragment extends BaseFragment implements AdvancedWebView.Listener { public static final String TAG = "web_fragment"; public static WebFragment newInstance() { Bundle args = new Bundle(); WebFragment fragment = new WebFragment(); fragment.setArguments(args); return fragment; } private AdvancedWebView mWebView; private View loadingLayout; private View errorLayout; @SuppressLint("SetJavaScriptEnabled") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_web, container, false); mWebView = view.findViewById(R.id.webview); loadingLayout = view.findViewById(R.id.loading_layout); errorLayout = view.findViewById(R.id.error_layout); errorLayout.findViewById(R.id.error_retry_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { errorLayout.setVisibility(View.GONE); loadingLayout.setVisibility(View.VISIBLE); mWebView.setVisibility(View.VISIBLE); mWebView.loadUrl("about:blank"); //Allow to change URL via Firebase FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
String webUrl = firebaseRemoteConfig.getString(Constants.FIREBASE_CONFIG_WEB_URL);
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/TileOverlayManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlay.java // public interface TileOverlay { // // void clearTileCache(); // // <T> T getData(); // // boolean getFadeIn(); // // @Deprecated // String getId(); // // float getZIndex(); // // float getTransparency(); // // boolean isVisible(); // // void remove(); // // void setData(Object data); // // void setFadeIn(boolean fadeIn); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlayOptions.java // public class TileOverlayOptions { // // public final com.google.android.gms.maps.model.TileOverlayOptions real = new com.google.android.gms.maps.model.TileOverlayOptions(); // private Object data; // // public TileOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public TileOverlayOptions fadeIn(boolean fadeIn) { // real.fadeIn(fadeIn); // return this; // } // // public Object getData() { // return data; // } // // public boolean getFadeIn() { // return real.getFadeIn(); // } // // public TileProvider getTileProvider() { // return real.getTileProvider(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public TileOverlayOptions tileProvider(TileProvider tileProvider) { // real.tileProvider(tileProvider); // return this; // } // // public TileOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public TileOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public TileOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.TileOverlay; import com.androidmapsextensions.TileOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class TileOverlayManager { private final IGoogleMap factory;
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlay.java // public interface TileOverlay { // // void clearTileCache(); // // <T> T getData(); // // boolean getFadeIn(); // // @Deprecated // String getId(); // // float getZIndex(); // // float getTransparency(); // // boolean isVisible(); // // void remove(); // // void setData(Object data); // // void setFadeIn(boolean fadeIn); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlayOptions.java // public class TileOverlayOptions { // // public final com.google.android.gms.maps.model.TileOverlayOptions real = new com.google.android.gms.maps.model.TileOverlayOptions(); // private Object data; // // public TileOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public TileOverlayOptions fadeIn(boolean fadeIn) { // real.fadeIn(fadeIn); // return this; // } // // public Object getData() { // return data; // } // // public boolean getFadeIn() { // return real.getFadeIn(); // } // // public TileProvider getTileProvider() { // return real.getTileProvider(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public TileOverlayOptions tileProvider(TileProvider tileProvider) { // real.tileProvider(tileProvider); // return this; // } // // public TileOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public TileOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public TileOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/TileOverlayManager.java import com.androidmapsextensions.TileOverlay; import com.androidmapsextensions.TileOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class TileOverlayManager { private final IGoogleMap factory;
private final Map<com.google.android.gms.maps.model.TileOverlay, TileOverlay> tileOverlays;
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/TileOverlayManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlay.java // public interface TileOverlay { // // void clearTileCache(); // // <T> T getData(); // // boolean getFadeIn(); // // @Deprecated // String getId(); // // float getZIndex(); // // float getTransparency(); // // boolean isVisible(); // // void remove(); // // void setData(Object data); // // void setFadeIn(boolean fadeIn); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlayOptions.java // public class TileOverlayOptions { // // public final com.google.android.gms.maps.model.TileOverlayOptions real = new com.google.android.gms.maps.model.TileOverlayOptions(); // private Object data; // // public TileOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public TileOverlayOptions fadeIn(boolean fadeIn) { // real.fadeIn(fadeIn); // return this; // } // // public Object getData() { // return data; // } // // public boolean getFadeIn() { // return real.getFadeIn(); // } // // public TileProvider getTileProvider() { // return real.getTileProvider(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public TileOverlayOptions tileProvider(TileProvider tileProvider) { // real.tileProvider(tileProvider); // return this; // } // // public TileOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public TileOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public TileOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.TileOverlay; import com.androidmapsextensions.TileOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class TileOverlayManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.TileOverlay, TileOverlay> tileOverlays; public TileOverlayManager(IGoogleMap factory) { this.factory = factory; this.tileOverlays = new HashMap<com.google.android.gms.maps.model.TileOverlay, TileOverlay>(); }
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlay.java // public interface TileOverlay { // // void clearTileCache(); // // <T> T getData(); // // boolean getFadeIn(); // // @Deprecated // String getId(); // // float getZIndex(); // // float getTransparency(); // // boolean isVisible(); // // void remove(); // // void setData(Object data); // // void setFadeIn(boolean fadeIn); // // void setTransparency(float transparency); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/TileOverlayOptions.java // public class TileOverlayOptions { // // public final com.google.android.gms.maps.model.TileOverlayOptions real = new com.google.android.gms.maps.model.TileOverlayOptions(); // private Object data; // // public TileOverlayOptions data(Object data) { // this.data = data; // return this; // } // // public TileOverlayOptions fadeIn(boolean fadeIn) { // real.fadeIn(fadeIn); // return this; // } // // public Object getData() { // return data; // } // // public boolean getFadeIn() { // return real.getFadeIn(); // } // // public TileProvider getTileProvider() { // return real.getTileProvider(); // } // // public float getTransparency() { // return real.getTransparency(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public TileOverlayOptions tileProvider(TileProvider tileProvider) { // real.tileProvider(tileProvider); // return this; // } // // public TileOverlayOptions transparency(float transparency) { // real.transparency(transparency); // return this; // } // // public TileOverlayOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public TileOverlayOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/TileOverlayManager.java import com.androidmapsextensions.TileOverlay; import com.androidmapsextensions.TileOverlayOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class TileOverlayManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.TileOverlay, TileOverlay> tileOverlays; public TileOverlayManager(IGoogleMap factory) { this.factory = factory; this.tileOverlays = new HashMap<com.google.android.gms.maps.model.TileOverlay, TileOverlay>(); }
public TileOverlay addTileOverlay(TileOverlayOptions tileOverlayOptions) {
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/components/LocalStringEditText.java
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // }
import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatEditText; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager;
package com.referendum.uoctubre.components; public class LocalStringEditText extends AppCompatEditText { public LocalStringEditText(Context context) { super(context); init(null, context); } public LocalStringEditText(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringEditText(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); final String hintStringId = a.getString(R.styleable.StringAttributes_hint_string_id); setString(stringId); setHintString(hintStringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // } // Path: app/src/main/java/com/referendum/uoctubre/components/LocalStringEditText.java import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatEditText; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager; package com.referendum.uoctubre.components; public class LocalStringEditText extends AppCompatEditText { public LocalStringEditText(Context context) { super(context); init(null, context); } public LocalStringEditText(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringEditText(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); final String hintStringId = a.getString(R.styleable.StringAttributes_hint_string_id); setString(stringId); setHintString(hintStringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
setText(StringsManager.getString(stringId));
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/components/LocalStringButton.java
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // }
import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatButton; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager;
package com.referendum.uoctubre.components; public class LocalStringButton extends AppCompatButton { public LocalStringButton(Context context) { super(context); init(null, context); } public LocalStringButton(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); setString(stringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // } // Path: app/src/main/java/com/referendum/uoctubre/components/LocalStringButton.java import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatButton; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager; package com.referendum.uoctubre.components; public class LocalStringButton extends AppCompatButton { public LocalStringButton(Context context) { super(context); init(null, context); } public LocalStringButton(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); setString(stringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
setText(StringsManager.getString(stringId));
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/utils/PollingStationDataFetcher.java
// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java // public class Constants { // public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB // public static final int TWEETS_PER_PAGE = 50; // // public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message"; // public static final String FIREBASE_CONFIG_WEB_URL = "web_url"; // public static final String FIREBASE_CONFIG_API_URL = "api_url"; // public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html"; // // public static final String TWITTER_CONSUMER_KEY = "XXXXXX"; // public static final String TWITTER_CONSUMER_SECRET = "XXXXXX"; // } // // Path: app/src/main/java/com/referendum/uoctubre/model/ColegiElectoral.java // public class ColegiElectoral implements Serializable { // // private String municipi; // private String local; // private String adresa; // private String districte; // private String seccio; // private String mesa; // // //TODO TO BE REMOVED // private int cp; // private double lat; // private double lon; // // public String getMunicipi() { // return municipi; // } // // public void setMunicipi(String municipi) { // this.municipi = municipi; // } // // public String getLocal() { // return local; // } // // public void setLocal(String local) { // this.local = local; // } // // public String getAdresa() { // return adresa; // } // // public void setAdresa(String adresa) { // this.adresa = adresa; // } // // public String getDistricte() { // return districte; // } // // public void setDistricte(String districte) { // this.districte = districte; // } // // public String getSeccio() { // return seccio; // } // // public void setSeccio(String seccio) { // this.seccio = seccio; // } // // public String getMesa() { // return mesa; // } // // public void setMesa(String mesa) { // this.mesa = mesa; // } // // public int getCp() { // return cp; // } // // public void setCp(int cp) { // this.cp = cp; // } // // public double getLat() { // return lat; // } // // public void setLat(double lat) { // this.lat = lat; // } // // public double getLon() { // return lon; // } // // public void setLon(double lon) { // this.lon = lon; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/model/PollingStationResponse.java // public class PollingStationResponse { // private String status; // private ColegiElectoral pollingStation; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public ColegiElectoral getPollingStation() { // return pollingStation; // } // // public void setPollingStation(ColegiElectoral pollingStation) { // this.pollingStation = pollingStation; // } // }
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.referendum.uoctubre.R; import com.referendum.uoctubre.main.Constants; import com.referendum.uoctubre.model.ColegiElectoral; import com.referendum.uoctubre.model.PollingStationResponse; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec;
package com.referendum.uoctubre.utils; public class PollingStationDataFetcher { public static PollingStationResponse getUserPollingStation(String nif, Date birthDate, int zipCode) { PollingStationResponse pollingStationResponse = new PollingStationResponse(); String keyDate = new SimpleDateFormat("yyyyMMdd", Locale.US).format(birthDate); String keyZipCode = String.format(Locale.US, "%05d", zipCode); String keyNif = nif.toUpperCase(Locale.US).substring(nif.length() - 6, nif.length()); String key = keyNif + keyDate + keyZipCode; String firstSha256 = hash(bucleHash(key)); String secondSha256 = hash(firstSha256); String dir = secondSha256.substring(0, 2); String file = secondSha256.substring(2, 4); FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java // public class Constants { // public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB // public static final int TWEETS_PER_PAGE = 50; // // public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message"; // public static final String FIREBASE_CONFIG_WEB_URL = "web_url"; // public static final String FIREBASE_CONFIG_API_URL = "api_url"; // public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html"; // // public static final String TWITTER_CONSUMER_KEY = "XXXXXX"; // public static final String TWITTER_CONSUMER_SECRET = "XXXXXX"; // } // // Path: app/src/main/java/com/referendum/uoctubre/model/ColegiElectoral.java // public class ColegiElectoral implements Serializable { // // private String municipi; // private String local; // private String adresa; // private String districte; // private String seccio; // private String mesa; // // //TODO TO BE REMOVED // private int cp; // private double lat; // private double lon; // // public String getMunicipi() { // return municipi; // } // // public void setMunicipi(String municipi) { // this.municipi = municipi; // } // // public String getLocal() { // return local; // } // // public void setLocal(String local) { // this.local = local; // } // // public String getAdresa() { // return adresa; // } // // public void setAdresa(String adresa) { // this.adresa = adresa; // } // // public String getDistricte() { // return districte; // } // // public void setDistricte(String districte) { // this.districte = districte; // } // // public String getSeccio() { // return seccio; // } // // public void setSeccio(String seccio) { // this.seccio = seccio; // } // // public String getMesa() { // return mesa; // } // // public void setMesa(String mesa) { // this.mesa = mesa; // } // // public int getCp() { // return cp; // } // // public void setCp(int cp) { // this.cp = cp; // } // // public double getLat() { // return lat; // } // // public void setLat(double lat) { // this.lat = lat; // } // // public double getLon() { // return lon; // } // // public void setLon(double lon) { // this.lon = lon; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/model/PollingStationResponse.java // public class PollingStationResponse { // private String status; // private ColegiElectoral pollingStation; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public ColegiElectoral getPollingStation() { // return pollingStation; // } // // public void setPollingStation(ColegiElectoral pollingStation) { // this.pollingStation = pollingStation; // } // } // Path: app/src/main/java/com/referendum/uoctubre/utils/PollingStationDataFetcher.java import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.referendum.uoctubre.R; import com.referendum.uoctubre.main.Constants; import com.referendum.uoctubre.model.ColegiElectoral; import com.referendum.uoctubre.model.PollingStationResponse; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; package com.referendum.uoctubre.utils; public class PollingStationDataFetcher { public static PollingStationResponse getUserPollingStation(String nif, Date birthDate, int zipCode) { PollingStationResponse pollingStationResponse = new PollingStationResponse(); String keyDate = new SimpleDateFormat("yyyyMMdd", Locale.US).format(birthDate); String keyZipCode = String.format(Locale.US, "%05d", zipCode); String keyNif = nif.toUpperCase(Locale.US).substring(nif.length() - 6, nif.length()); String key = keyNif + keyDate + keyZipCode; String firstSha256 = hash(bucleHash(key)); String secondSha256 = hash(firstSha256); String dir = secondSha256.substring(0, 2); String file = secondSha256.substring(2, 4); FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
String api = firebaseRemoteConfig.getString(Constants.FIREBASE_CONFIG_API_URL);
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/utils/PollingStationDataFetcher.java
// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java // public class Constants { // public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB // public static final int TWEETS_PER_PAGE = 50; // // public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message"; // public static final String FIREBASE_CONFIG_WEB_URL = "web_url"; // public static final String FIREBASE_CONFIG_API_URL = "api_url"; // public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html"; // // public static final String TWITTER_CONSUMER_KEY = "XXXXXX"; // public static final String TWITTER_CONSUMER_SECRET = "XXXXXX"; // } // // Path: app/src/main/java/com/referendum/uoctubre/model/ColegiElectoral.java // public class ColegiElectoral implements Serializable { // // private String municipi; // private String local; // private String adresa; // private String districte; // private String seccio; // private String mesa; // // //TODO TO BE REMOVED // private int cp; // private double lat; // private double lon; // // public String getMunicipi() { // return municipi; // } // // public void setMunicipi(String municipi) { // this.municipi = municipi; // } // // public String getLocal() { // return local; // } // // public void setLocal(String local) { // this.local = local; // } // // public String getAdresa() { // return adresa; // } // // public void setAdresa(String adresa) { // this.adresa = adresa; // } // // public String getDistricte() { // return districte; // } // // public void setDistricte(String districte) { // this.districte = districte; // } // // public String getSeccio() { // return seccio; // } // // public void setSeccio(String seccio) { // this.seccio = seccio; // } // // public String getMesa() { // return mesa; // } // // public void setMesa(String mesa) { // this.mesa = mesa; // } // // public int getCp() { // return cp; // } // // public void setCp(int cp) { // this.cp = cp; // } // // public double getLat() { // return lat; // } // // public void setLat(double lat) { // this.lat = lat; // } // // public double getLon() { // return lon; // } // // public void setLon(double lon) { // this.lon = lon; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/model/PollingStationResponse.java // public class PollingStationResponse { // private String status; // private ColegiElectoral pollingStation; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public ColegiElectoral getPollingStation() { // return pollingStation; // } // // public void setPollingStation(ColegiElectoral pollingStation) { // this.pollingStation = pollingStation; // } // }
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.referendum.uoctubre.R; import com.referendum.uoctubre.main.Constants; import com.referendum.uoctubre.model.ColegiElectoral; import com.referendum.uoctubre.model.PollingStationResponse; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec;
URL url = new URL(api + dir + "/" + file + ".db"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(30000); conn.setReadTimeout(30000); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); StringBuilder resultStringBuilder = new StringBuilder(); String str; while ((str = in.readLine()) != null) { if (resultStringBuilder.length() != 0) { resultStringBuilder.append("\n"); } resultStringBuilder.append(str); } in.close(); String[] lines = resultStringBuilder.toString().split("\n"); String result = null; for (String line : lines) { if (line.substring(0, 60).equals(secondSha256.substring(4))) { result = decrypt(line.substring(60), firstSha256); } } if (result != null) { String[] info = result.split("#");
// Path: app/src/main/java/com/referendum/uoctubre/main/Constants.java // public class Constants { // public static final int MAX_FIREBASE_DOWNLOAD_SIZE = 1024 * 1024; //1MB // public static final int TWEETS_PER_PAGE = 50; // // public static final String FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED = "share_app_message"; // public static final String FIREBASE_CONFIG_WEB_URL = "web_url"; // public static final String FIREBASE_CONFIG_API_URL = "api_url"; // public static final String PRIVACY_POLICY_URL = "https://htmlpreview.github.io/?https://github.com/mosquitolabs/referendum_1o_android/blob/master/privacy_policy.html"; // // public static final String TWITTER_CONSUMER_KEY = "XXXXXX"; // public static final String TWITTER_CONSUMER_SECRET = "XXXXXX"; // } // // Path: app/src/main/java/com/referendum/uoctubre/model/ColegiElectoral.java // public class ColegiElectoral implements Serializable { // // private String municipi; // private String local; // private String adresa; // private String districte; // private String seccio; // private String mesa; // // //TODO TO BE REMOVED // private int cp; // private double lat; // private double lon; // // public String getMunicipi() { // return municipi; // } // // public void setMunicipi(String municipi) { // this.municipi = municipi; // } // // public String getLocal() { // return local; // } // // public void setLocal(String local) { // this.local = local; // } // // public String getAdresa() { // return adresa; // } // // public void setAdresa(String adresa) { // this.adresa = adresa; // } // // public String getDistricte() { // return districte; // } // // public void setDistricte(String districte) { // this.districte = districte; // } // // public String getSeccio() { // return seccio; // } // // public void setSeccio(String seccio) { // this.seccio = seccio; // } // // public String getMesa() { // return mesa; // } // // public void setMesa(String mesa) { // this.mesa = mesa; // } // // public int getCp() { // return cp; // } // // public void setCp(int cp) { // this.cp = cp; // } // // public double getLat() { // return lat; // } // // public void setLat(double lat) { // this.lat = lat; // } // // public double getLon() { // return lon; // } // // public void setLon(double lon) { // this.lon = lon; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/model/PollingStationResponse.java // public class PollingStationResponse { // private String status; // private ColegiElectoral pollingStation; // // public String getStatus() { // return status; // } // // public void setStatus(String status) { // this.status = status; // } // // public ColegiElectoral getPollingStation() { // return pollingStation; // } // // public void setPollingStation(ColegiElectoral pollingStation) { // this.pollingStation = pollingStation; // } // } // Path: app/src/main/java/com/referendum/uoctubre/utils/PollingStationDataFetcher.java import com.google.firebase.remoteconfig.FirebaseRemoteConfig; import com.referendum.uoctubre.R; import com.referendum.uoctubre.main.Constants; import com.referendum.uoctubre.model.ColegiElectoral; import com.referendum.uoctubre.model.PollingStationResponse; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; URL url = new URL(api + dir + "/" + file + ".db"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setConnectTimeout(30000); conn.setReadTimeout(30000); BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); StringBuilder resultStringBuilder = new StringBuilder(); String str; while ((str = in.readLine()) != null) { if (resultStringBuilder.length() != 0) { resultStringBuilder.append("\n"); } resultStringBuilder.append(str); } in.close(); String[] lines = resultStringBuilder.toString().split("\n"); String result = null; for (String line : lines) { if (line.substring(0, 60).equals(secondSha256.substring(4))) { result = decrypt(line.substring(60), firstSha256); } } if (result != null) { String[] info = result.split("#");
ColegiElectoral colegiElectoral = new ColegiElectoral();
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/NoClusteringStrategy.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // }
import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.CameraPosition; import java.util.List;
public void onClusterGroupChange(DelegatingMarker marker) { } @Override public void onAdd(DelegatingMarker marker) { } @Override public void onRemove(DelegatingMarker marker) { } @Override public void onPositionChange(DelegatingMarker marker) { } @Override public void onVisibilityChangeRequest(DelegatingMarker marker, boolean visible) { marker.changeVisible(visible); } @Override public void onShowInfoWindow(DelegatingMarker marker) { marker.forceShowInfoWindow(); } @Override
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/NoClusteringStrategy.java import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.CameraPosition; import java.util.List; public void onClusterGroupChange(DelegatingMarker marker) { } @Override public void onAdd(DelegatingMarker marker) { } @Override public void onRemove(DelegatingMarker marker) { } @Override public void onPositionChange(DelegatingMarker marker) { } @Override public void onVisibilityChangeRequest(DelegatingMarker marker, boolean visible) { marker.changeVisible(visible); } @Override public void onShowInfoWindow(DelegatingMarker marker) { marker.forceShowInfoWindow(); } @Override
public Marker map(com.google.android.gms.maps.model.Marker original) {
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/utils/SharedPreferencesUtils.java
// Path: app/src/main/java/com/referendum/uoctubre/UOctubreApplication.java // public class UOctubreApplication extends Application { // // private static UOctubreApplication sInstance; // // @Override // public void onCreate() { // super.onCreate(); // // sInstance = this; // // Fabric.with(this, new Crashlytics()); // // StringsManager.initialize(); // // TwitterConfig config = new TwitterConfig.Builder(this) // .logger(new DefaultLogger(Log.DEBUG)) // .twitterAuthConfig(new TwitterAuthConfig(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET)) // .debug(true) // .build(); // Twitter.initialize(config); // // //Create Notification channel in Android O // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // if (notificationManager != null) { // NotificationChannel mChannel = new NotificationChannel("referendum", // StringsManager.getString("notification_channel_name"), NotificationManager.IMPORTANCE_HIGH); // mChannel.setDescription(StringsManager.getString("notification_channel_description")); // mChannel.enableLights(true); // mChannel.setLightColor(Color.RED); // notificationManager.createNotificationChannel(mChannel); // } // } // } // // public static UOctubreApplication getInstance() { // return sInstance; // } // }
import android.content.SharedPreferences; import android.preference.PreferenceManager; import com.referendum.uoctubre.UOctubreApplication; import java.util.HashSet; import java.util.Set;
/* * Copyright (c) 2017 Tadaima.cat. All rights reserved. */ package com.referendum.uoctubre.utils; public class SharedPreferencesUtils { public static final String USER_HASHTAGS = "user_hashtags"; public static final String APP_LANGUAGE = "app_language"; public static final String NUMBER_OF_EXECUTIONS = "number_of_executions"; public static final String HAS_RATED = "has_rated"; public static String getString(String key, String defaultValue) {
// Path: app/src/main/java/com/referendum/uoctubre/UOctubreApplication.java // public class UOctubreApplication extends Application { // // private static UOctubreApplication sInstance; // // @Override // public void onCreate() { // super.onCreate(); // // sInstance = this; // // Fabric.with(this, new Crashlytics()); // // StringsManager.initialize(); // // TwitterConfig config = new TwitterConfig.Builder(this) // .logger(new DefaultLogger(Log.DEBUG)) // .twitterAuthConfig(new TwitterAuthConfig(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET)) // .debug(true) // .build(); // Twitter.initialize(config); // // //Create Notification channel in Android O // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // if (notificationManager != null) { // NotificationChannel mChannel = new NotificationChannel("referendum", // StringsManager.getString("notification_channel_name"), NotificationManager.IMPORTANCE_HIGH); // mChannel.setDescription(StringsManager.getString("notification_channel_description")); // mChannel.enableLights(true); // mChannel.setLightColor(Color.RED); // notificationManager.createNotificationChannel(mChannel); // } // } // } // // public static UOctubreApplication getInstance() { // return sInstance; // } // } // Path: app/src/main/java/com/referendum/uoctubre/utils/SharedPreferencesUtils.java import android.content.SharedPreferences; import android.preference.PreferenceManager; import com.referendum.uoctubre.UOctubreApplication; import java.util.HashSet; import java.util.Set; /* * Copyright (c) 2017 Tadaima.cat. All rights reserved. */ package com.referendum.uoctubre.utils; public class SharedPreferencesUtils { public static final String USER_HASHTAGS = "user_hashtags"; public static final String APP_LANGUAGE = "app_language"; public static final String NUMBER_OF_EXECUTIONS = "number_of_executions"; public static final String HAS_RATED = "has_rated"; public static String getString(String key, String defaultValue) {
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(UOctubreApplication.getInstance());
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/CircleManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/CircleOptions.java // public class CircleOptions { // // public final com.google.android.gms.maps.model.CircleOptions real = new com.google.android.gms.maps.model.CircleOptions(); // private Object data; // // public CircleOptions center(LatLng center) { // real.center(center); // return this; // } // // public CircleOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public CircleOptions data(Object data) { // this.data = data; // return this; // } // // public CircleOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public LatLng getCenter() { // return real.getCenter(); // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public double getRadius() { // return real.getRadius(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public CircleOptions radius(double radius) { // real.radius(radius); // return this; // } // // public CircleOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public CircleOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public CircleOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public CircleOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public CircleOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnCircleClickListener { // // void onCircleClick(Circle circle); // }
import com.androidmapsextensions.Circle; import com.androidmapsextensions.CircleOptions; import com.androidmapsextensions.GoogleMap.OnCircleClickListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class CircleManager { private final IGoogleMap factory;
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/CircleOptions.java // public class CircleOptions { // // public final com.google.android.gms.maps.model.CircleOptions real = new com.google.android.gms.maps.model.CircleOptions(); // private Object data; // // public CircleOptions center(LatLng center) { // real.center(center); // return this; // } // // public CircleOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public CircleOptions data(Object data) { // this.data = data; // return this; // } // // public CircleOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public LatLng getCenter() { // return real.getCenter(); // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public double getRadius() { // return real.getRadius(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public CircleOptions radius(double radius) { // real.radius(radius); // return this; // } // // public CircleOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public CircleOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public CircleOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public CircleOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public CircleOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnCircleClickListener { // // void onCircleClick(Circle circle); // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/CircleManager.java import com.androidmapsextensions.Circle; import com.androidmapsextensions.CircleOptions; import com.androidmapsextensions.GoogleMap.OnCircleClickListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class CircleManager { private final IGoogleMap factory;
private final Map<com.google.android.gms.maps.model.Circle, Circle> circles;
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/CircleManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/CircleOptions.java // public class CircleOptions { // // public final com.google.android.gms.maps.model.CircleOptions real = new com.google.android.gms.maps.model.CircleOptions(); // private Object data; // // public CircleOptions center(LatLng center) { // real.center(center); // return this; // } // // public CircleOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public CircleOptions data(Object data) { // this.data = data; // return this; // } // // public CircleOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public LatLng getCenter() { // return real.getCenter(); // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public double getRadius() { // return real.getRadius(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public CircleOptions radius(double radius) { // real.radius(radius); // return this; // } // // public CircleOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public CircleOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public CircleOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public CircleOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public CircleOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnCircleClickListener { // // void onCircleClick(Circle circle); // }
import com.androidmapsextensions.Circle; import com.androidmapsextensions.CircleOptions; import com.androidmapsextensions.GoogleMap.OnCircleClickListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class CircleManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Circle, Circle> circles; public CircleManager(IGoogleMap factory) { this.factory = factory; this.circles = new HashMap<>(); }
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/CircleOptions.java // public class CircleOptions { // // public final com.google.android.gms.maps.model.CircleOptions real = new com.google.android.gms.maps.model.CircleOptions(); // private Object data; // // public CircleOptions center(LatLng center) { // real.center(center); // return this; // } // // public CircleOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public CircleOptions data(Object data) { // this.data = data; // return this; // } // // public CircleOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public LatLng getCenter() { // return real.getCenter(); // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public double getRadius() { // return real.getRadius(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public CircleOptions radius(double radius) { // real.radius(radius); // return this; // } // // public CircleOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public CircleOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public CircleOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public CircleOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public CircleOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnCircleClickListener { // // void onCircleClick(Circle circle); // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/CircleManager.java import com.androidmapsextensions.Circle; import com.androidmapsextensions.CircleOptions; import com.androidmapsextensions.GoogleMap.OnCircleClickListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class CircleManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Circle, Circle> circles; public CircleManager(IGoogleMap factory) { this.factory = factory; this.circles = new HashMap<>(); }
public Circle addCircle(CircleOptions circleOptions) {
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/CircleManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/CircleOptions.java // public class CircleOptions { // // public final com.google.android.gms.maps.model.CircleOptions real = new com.google.android.gms.maps.model.CircleOptions(); // private Object data; // // public CircleOptions center(LatLng center) { // real.center(center); // return this; // } // // public CircleOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public CircleOptions data(Object data) { // this.data = data; // return this; // } // // public CircleOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public LatLng getCenter() { // return real.getCenter(); // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public double getRadius() { // return real.getRadius(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public CircleOptions radius(double radius) { // real.radius(radius); // return this; // } // // public CircleOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public CircleOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public CircleOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public CircleOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public CircleOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnCircleClickListener { // // void onCircleClick(Circle circle); // }
import com.androidmapsextensions.Circle; import com.androidmapsextensions.CircleOptions; import com.androidmapsextensions.GoogleMap.OnCircleClickListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class CircleManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Circle, Circle> circles; public CircleManager(IGoogleMap factory) { this.factory = factory; this.circles = new HashMap<>(); } public Circle addCircle(CircleOptions circleOptions) { Circle circle = createCircle(circleOptions.real); circle.setData(circleOptions.getData()); return circle; } private Circle createCircle(com.google.android.gms.maps.model.CircleOptions circleOptions) { com.google.android.gms.maps.model.Circle real = factory.addCircle(circleOptions); Circle circle = new DelegatingCircle(real, this); circles.put(real, circle); return circle; } public void clear() { circles.clear(); } public List<Circle> getCircles() { return new ArrayList<Circle>(circles.values()); } public void onRemove(com.google.android.gms.maps.model.Circle real) { circles.remove(real); }
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/CircleOptions.java // public class CircleOptions { // // public final com.google.android.gms.maps.model.CircleOptions real = new com.google.android.gms.maps.model.CircleOptions(); // private Object data; // // public CircleOptions center(LatLng center) { // real.center(center); // return this; // } // // public CircleOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public CircleOptions data(Object data) { // this.data = data; // return this; // } // // public CircleOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public LatLng getCenter() { // return real.getCenter(); // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public double getRadius() { // return real.getRadius(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public CircleOptions radius(double radius) { // real.radius(radius); // return this; // } // // public CircleOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public CircleOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public CircleOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public CircleOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public CircleOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnCircleClickListener { // // void onCircleClick(Circle circle); // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/CircleManager.java import com.androidmapsextensions.Circle; import com.androidmapsextensions.CircleOptions; import com.androidmapsextensions.GoogleMap.OnCircleClickListener; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class CircleManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Circle, Circle> circles; public CircleManager(IGoogleMap factory) { this.factory = factory; this.circles = new HashMap<>(); } public Circle addCircle(CircleOptions circleOptions) { Circle circle = createCircle(circleOptions.real); circle.setData(circleOptions.getData()); return circle; } private Circle createCircle(com.google.android.gms.maps.model.CircleOptions circleOptions) { com.google.android.gms.maps.model.Circle real = factory.addCircle(circleOptions); Circle circle = new DelegatingCircle(real, this); circles.put(real, circle); return circle; } public void clear() { circles.clear(); } public List<Circle> getCircles() { return new ArrayList<Circle>(circles.values()); } public void onRemove(com.google.android.gms.maps.model.Circle real) { circles.remove(real); }
public void setOnCircleClickListener(OnCircleClickListener onCircleClickListener) {
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/components/LocalStringImageView.java
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // }
import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatImageView; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager;
package com.referendum.uoctubre.components; public class LocalStringImageView extends AppCompatImageView { public LocalStringImageView(Context context) { super(context); init(null, context); } public LocalStringImageView(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String contentDescriptionStringId = a.getString(R.styleable.StringAttributes_content_description_string_id); setContentDescriptionString(contentDescriptionStringId); a.recycle(); } private void setContentDescriptionString(String contentDescriptionStringId) { if (TextUtils.isEmpty(contentDescriptionStringId)) { return; } if (this.isInEditMode()) { setContentDescription(contentDescriptionStringId); } else {
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // } // Path: app/src/main/java/com/referendum/uoctubre/components/LocalStringImageView.java import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatImageView; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager; package com.referendum.uoctubre.components; public class LocalStringImageView extends AppCompatImageView { public LocalStringImageView(Context context) { super(context); init(null, context); } public LocalStringImageView(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String contentDescriptionStringId = a.getString(R.styleable.StringAttributes_content_description_string_id); setContentDescriptionString(contentDescriptionStringId); a.recycle(); } private void setContentDescriptionString(String contentDescriptionStringId) { if (TextUtils.isEmpty(contentDescriptionStringId)) { return; } if (this.isInEditMode()) { setContentDescription(contentDescriptionStringId); } else {
setContentDescription(StringsManager.getString(contentDescriptionStringId));
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/gcm/MyFirebaseMessagingService.java
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // }
import android.app.NotificationManager; import android.content.Context; import android.graphics.BitmapFactory; import android.support.v4.app.NotificationCompat; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager;
package com.referendum.uoctubre.gcm; public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "FCM Service"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { if (remoteMessage != null && remoteMessage.getNotification() != null) { Log.d(TAG, "From: " + remoteMessage.getFrom()); Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody()); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "referendum") .setLargeIcon(BitmapFactory.decodeResource( getResources(), R.mipmap.ic_launcher)) .setSmallIcon(R.drawable.ic_notification)
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // } // Path: app/src/main/java/com/referendum/uoctubre/gcm/MyFirebaseMessagingService.java import android.app.NotificationManager; import android.content.Context; import android.graphics.BitmapFactory; import android.support.v4.app.NotificationCompat; import android.util.Log; import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager; package com.referendum.uoctubre.gcm; public class MyFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG = "FCM Service"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { if (remoteMessage != null && remoteMessage.getNotification() != null) { Log.d(TAG, "From: " + remoteMessage.getFrom()); Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody()); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "referendum") .setLargeIcon(BitmapFactory.decodeResource( getResources(), R.mipmap.ic_launcher)) .setSmallIcon(R.drawable.ic_notification)
.setContentTitle(StringsManager.getString("notification_title"))
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/MapHolder.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/ExtendedMapFactory.java // public final class ExtendedMapFactory { // // private ExtendedMapFactory() { // } // // public static GoogleMap create(com.google.android.gms.maps.GoogleMap real, Context context) { // return new DelegatingGoogleMap(new GoogleMapWrapper(real), context); // } // }
import android.content.Context; import com.androidmapsextensions.impl.ExtendedMapFactory; import java.lang.reflect.Method;
package com.androidmapsextensions; final class MapHolder { public interface Delegate { // This function no longer exist in new versions of Google Maps Android API v2, // so we get access to it via reflection whenever possible //com.google.android.gms.maps.GoogleMap getMap(); void getMapAsync(com.google.android.gms.maps.OnMapReadyCallback callback); Context getContext(); } private final Delegate delegate; private GoogleMap map; public MapHolder(Delegate delegate) { this.delegate = delegate; } public GoogleMap getExtendedMap() { if (map == null) { try { Method getMapMethod = delegate.getClass().getMethod("getMap"); Object obj = getMapMethod.invoke(delegate); if (obj != null) { com.google.android.gms.maps.GoogleMap realMap = (com.google.android.gms.maps.GoogleMap) obj;
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/ExtendedMapFactory.java // public final class ExtendedMapFactory { // // private ExtendedMapFactory() { // } // // public static GoogleMap create(com.google.android.gms.maps.GoogleMap real, Context context) { // return new DelegatingGoogleMap(new GoogleMapWrapper(real), context); // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/MapHolder.java import android.content.Context; import com.androidmapsextensions.impl.ExtendedMapFactory; import java.lang.reflect.Method; package com.androidmapsextensions; final class MapHolder { public interface Delegate { // This function no longer exist in new versions of Google Maps Android API v2, // so we get access to it via reflection whenever possible //com.google.android.gms.maps.GoogleMap getMap(); void getMapAsync(com.google.android.gms.maps.OnMapReadyCallback callback); Context getContext(); } private final Delegate delegate; private GoogleMap map; public MapHolder(Delegate delegate) { this.delegate = delegate; } public GoogleMap getExtendedMap() { if (map == null) { try { Method getMapMethod = delegate.getClass().getMethod("getMap"); Object obj = getMapMethod.invoke(delegate); if (obj != null) { com.google.android.gms.maps.GoogleMap realMap = (com.google.android.gms.maps.GoogleMap) obj;
map = ExtendedMapFactory.create(realMap, delegate.getContext());
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/DelegatingCircle.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/utils/LatLngUtils.java // public final class LatLngUtils { // // private LatLngUtils() { // } // // public static float distanceBetween(LatLng first, LatLng second) { // float[] distance = new float[1]; // Location.distanceBetween(first.latitude, first.longitude, second.latitude, second.longitude, distance); // return distance[0]; // } // // public static LatLng fromLocation(Location location) { // return new LatLng(location.getLatitude(), location.getLongitude()); // } // }
import com.androidmapsextensions.Circle; import com.androidmapsextensions.utils.LatLngUtils; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.PatternItem; import java.util.List;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class DelegatingCircle implements Circle { private com.google.android.gms.maps.model.Circle real; private CircleManager manager; private Object data; DelegatingCircle(com.google.android.gms.maps.model.Circle real, CircleManager manager) { this.real = real; this.manager = manager; } @Override public boolean contains(LatLng position) { LatLng center = getCenter(); double radius = getRadius();
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Circle.java // public interface Circle { // // boolean contains(LatLng position); // // LatLng getCenter(); // // <T> T getData(); // // int getFillColor(); // // @Deprecated // String getId(); // // double getRadius(); // // int getStrokeColor(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isVisible(); // // void remove(); // // void setCenter(LatLng center); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setRadius(double radius); // // void setStrokeColor(int strokeColor); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/utils/LatLngUtils.java // public final class LatLngUtils { // // private LatLngUtils() { // } // // public static float distanceBetween(LatLng first, LatLng second) { // float[] distance = new float[1]; // Location.distanceBetween(first.latitude, first.longitude, second.latitude, second.longitude, distance); // return distance[0]; // } // // public static LatLng fromLocation(Location location) { // return new LatLng(location.getLatitude(), location.getLongitude()); // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/DelegatingCircle.java import com.androidmapsextensions.Circle; import com.androidmapsextensions.utils.LatLngUtils; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.PatternItem; import java.util.List; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class DelegatingCircle implements Circle { private com.google.android.gms.maps.model.Circle real; private CircleManager manager; private Object data; DelegatingCircle(com.google.android.gms.maps.model.Circle real, CircleManager manager) { this.real = real; this.manager = manager; } @Override public boolean contains(LatLng position) { LatLng center = getCenter(); double radius = getRadius();
float distance = LatLngUtils.distanceBetween(position, center);
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/components/LocalStringTextView.java
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // }
import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatTextView; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager;
package com.referendum.uoctubre.components; public class LocalStringTextView extends AppCompatTextView { public LocalStringTextView(Context context) { super(context); init(null, context); } public LocalStringTextView(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); setString(stringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // } // Path: app/src/main/java/com/referendum/uoctubre/components/LocalStringTextView.java import android.content.Context; import android.content.res.TypedArray; import android.support.v7.widget.AppCompatTextView; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager; package com.referendum.uoctubre.components; public class LocalStringTextView extends AppCompatTextView { public LocalStringTextView(Context context) { super(context); init(null, context); } public LocalStringTextView(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); setString(stringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
setText(StringsManager.getString(stringId));
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/components/LocalStringTextInputEditText.java
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // }
import android.content.Context; import android.content.res.TypedArray; import android.support.design.widget.TextInputEditText; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager;
package com.referendum.uoctubre.components; public class LocalStringTextInputEditText extends TextInputEditText { public LocalStringTextInputEditText(Context context) { super(context); init(null, context); } public LocalStringTextInputEditText(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringTextInputEditText(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); final String hintStringId = a.getString(R.styleable.StringAttributes_hint_string_id); setString(stringId); setHintString(hintStringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
// Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java // public class StringsManager { // // protected static final String TAG = StringsManager.class.getSimpleName(); // // private static final Object lock = new Object(); // private static String currentLanguage; // private static HashMap<String, CharSequence> mStrings; // // public static void initialize() { // currentLanguage = SharedPreferencesUtils.getString(SharedPreferencesUtils.APP_LANGUAGE, "ca"); // mStrings = new HashMap<>(); // refreshLiterals(); // } // // public static String getString(String id, Object... args) { // synchronized (lock) { // if (mStrings.containsKey(id)) { // try { // return String.format(mStrings.get(id).toString(), args); // } catch (IllegalFormatException e) { // Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); // return mStrings.get(id).toString(); // } // } else { // Crashlytics.logException(new RuntimeException("String not found: " + id)); // return ""; // } // } // // } // // private static void refreshLiterals() { // synchronized (lock) { // mStrings.clear(); // loadStringsFromResourceFile(); // } // } // // private static void loadStringsFromResourceFile() { // try { // Resources res = UOctubreApplication.getInstance().getResources(); // InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml"); // XmlPullParser parser = Xml.newPullParser(); // parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); // parser.setInput(in, null); // parser.nextTag(); // readStrings(parser); // in.close(); // // } catch (XmlPullParserException | IOException e) { // throw new RuntimeException(e); // } // } // // private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException { // parser.require(XmlPullParser.START_TAG, null, "resources"); // while (parser.next() != XmlPullParser.END_TAG) { // if (parser.getEventType() != XmlPullParser.START_TAG) { // continue; // } // String name = parser.getName(); // if (name.equals("string")) { // readString(parser); // } else { // skip(parser); // } // } // } // // private static void readString(XmlPullParser parser) throws IOException, XmlPullParserException { // parser.require(XmlPullParser.START_TAG, null, "string"); // String stringName = parser.getAttributeValue(null, "name"); // String value = getInnerXml(parser); // parser.require(XmlPullParser.END_TAG, null, "string"); // mStrings.put(stringName, value.replace("\\n", "\n")); // } // // private static String getInnerXml(XmlPullParser parser) throws XmlPullParserException, IOException { // StringBuilder sb = new StringBuilder(); // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // if (depth > 0) { // sb.append("</").append(parser.getName()).append(">"); // } // break; // case XmlPullParser.START_TAG: // depth++; // StringBuilder attrs = new StringBuilder(); // for (int i = 0; i < parser.getAttributeCount(); i++) { // attrs.append(parser.getAttributeName(i)).append("=\"").append(parser.getAttributeValue(i)).append("\" "); // } // sb.append("<").append(parser.getName()).append(" ").append(attrs.toString()).append(">"); // break; // default: // sb.append(parser.getText()); // break; // } // } // return sb.toString(); // } // // private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { // if (parser.getEventType() != XmlPullParser.START_TAG) { // throw new IllegalStateException(); // } // int depth = 1; // while (depth != 0) { // switch (parser.next()) { // case XmlPullParser.END_TAG: // depth--; // break; // case XmlPullParser.START_TAG: // depth++; // break; // } // } // } // // public static String getCurrentLanguage() { // return currentLanguage; // } // // public static void setLanguage(String language) { // SharedPreferencesUtils.setString(SharedPreferencesUtils.APP_LANGUAGE, language); // currentLanguage = language; // refreshLiterals(); // } // } // Path: app/src/main/java/com/referendum/uoctubre/components/LocalStringTextInputEditText.java import android.content.Context; import android.content.res.TypedArray; import android.support.design.widget.TextInputEditText; import android.text.TextUtils; import android.util.AttributeSet; import com.referendum.uoctubre.R; import com.referendum.uoctubre.utils.StringsManager; package com.referendum.uoctubre.components; public class LocalStringTextInputEditText extends TextInputEditText { public LocalStringTextInputEditText(Context context) { super(context); init(null, context); } public LocalStringTextInputEditText(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, context); } public LocalStringTextInputEditText(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, context); } public void init(AttributeSet attrs, final Context context) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StringAttributes); final String stringId = a.getString(R.styleable.StringAttributes_string_id); final String hintStringId = a.getString(R.styleable.StringAttributes_hint_string_id); setString(stringId); setHintString(hintStringId); a.recycle(); } private void setString(String stringId) { if (TextUtils.isEmpty(stringId)) { return; } if (this.isInEditMode()) { setText(stringId); } else {
setText(StringsManager.getString(stringId));
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/DebugHelper.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/utils/SphericalMercator.java // public final class SphericalMercator { // // private static final double MIN_LATITUDE = -85.0511287798; // private static final double MAX_LATITUDE = 85.0511287798; // // private SphericalMercator() { // } // // public static double fromLatitude(double latitude) { // double radians = Math.toRadians(latitude + 90) / 2; // return Math.toDegrees(Math.log(Math.tan(radians))); // } // // public static double toLatitude(double mercator) { // double radians = Math.atan(Math.exp(Math.toRadians(mercator))); // return Math.toDegrees(2 * radians) - 90; // } // // /** // * @param latitude to be scaled // * @return value in the range [0, 360) // */ // public static double scaleLatitude(double latitude) { // if (latitude < MIN_LATITUDE) { // latitude = MIN_LATITUDE; // } else if (latitude > MAX_LATITUDE) { // latitude = MAX_LATITUDE; // } // return fromLatitude(latitude) + 180.0; // } // // /** // * @param longitude to be scaled // * @return value in the range [0, 360) // */ // public static double scaleLongitude(double longitude) { // return longitude + 180.0; // } // }
import com.androidmapsextensions.utils.SphericalMercator; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.Polyline; import com.google.android.gms.maps.model.PolylineOptions; import java.util.ArrayList; import java.util.List;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class DebugHelper { private List<Polyline> gridLines = new ArrayList<Polyline>(); void drawDebugGrid(IGoogleMap map, double clusterSize) { cleanup(); IProjection projection = map.getProjection(); LatLngBounds bounds = projection.getVisibleRegion().latLngBounds;
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/utils/SphericalMercator.java // public final class SphericalMercator { // // private static final double MIN_LATITUDE = -85.0511287798; // private static final double MAX_LATITUDE = 85.0511287798; // // private SphericalMercator() { // } // // public static double fromLatitude(double latitude) { // double radians = Math.toRadians(latitude + 90) / 2; // return Math.toDegrees(Math.log(Math.tan(radians))); // } // // public static double toLatitude(double mercator) { // double radians = Math.atan(Math.exp(Math.toRadians(mercator))); // return Math.toDegrees(2 * radians) - 90; // } // // /** // * @param latitude to be scaled // * @return value in the range [0, 360) // */ // public static double scaleLatitude(double latitude) { // if (latitude < MIN_LATITUDE) { // latitude = MIN_LATITUDE; // } else if (latitude > MAX_LATITUDE) { // latitude = MAX_LATITUDE; // } // return fromLatitude(latitude) + 180.0; // } // // /** // * @param longitude to be scaled // * @return value in the range [0, 360) // */ // public static double scaleLongitude(double longitude) { // return longitude + 180.0; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/DebugHelper.java import com.androidmapsextensions.utils.SphericalMercator; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.Polyline; import com.google.android.gms.maps.model.PolylineOptions; import java.util.ArrayList; import java.util.List; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class DebugHelper { private List<Polyline> gridLines = new ArrayList<Polyline>(); void drawDebugGrid(IGoogleMap map, double clusterSize) { cleanup(); IProjection projection = map.getProjection(); LatLngBounds bounds = projection.getVisibleRegion().latLngBounds;
double minY = -180 + clusterSize * (int) (SphericalMercator.scaleLatitude(bounds.southwest.latitude) / clusterSize);
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/DynamicNoClusteringStrategy.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // }
import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.VisibleRegion; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set;
if (markers.contains(marker)) { if (visibleRegionBounds.contains(marker.getPosition())) { markers.remove(marker); marker.changeVisible(true); } } } @Override public void onVisibilityChangeRequest(DelegatingMarker marker, boolean visible) { if (visible) { addMarker(marker); } else { markers.remove(marker); marker.changeVisible(false); } } @Override public void onShowInfoWindow(DelegatingMarker marker) { if (!marker.isVisible()) { return; } if (markers.remove(marker)) { marker.changeVisible(true); } marker.forceShowInfoWindow(); } @Override
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/DynamicNoClusteringStrategy.java import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.VisibleRegion; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; if (markers.contains(marker)) { if (visibleRegionBounds.contains(marker.getPosition())) { markers.remove(marker); marker.changeVisible(true); } } } @Override public void onVisibilityChangeRequest(DelegatingMarker marker, boolean visible) { if (visible) { addMarker(marker); } else { markers.remove(marker); marker.changeVisible(false); } } @Override public void onShowInfoWindow(DelegatingMarker marker) { if (!marker.isVisible()) { return; } if (markers.remove(marker)) { marker.changeVisible(true); } marker.forceShowInfoWindow(); } @Override
public Marker map(com.google.android.gms.maps.model.Marker original) {
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/ClusteringStrategy.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // }
import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.CameraPosition; import java.util.List;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; interface ClusteringStrategy { void cleanup(); void onCameraChange(CameraPosition cameraPosition); void onClusterGroupChange(DelegatingMarker marker); void onAdd(DelegatingMarker marker); void onRemove(DelegatingMarker marker); void onPositionChange(DelegatingMarker marker); void onVisibilityChangeRequest(DelegatingMarker marker, boolean visible); void onShowInfoWindow(DelegatingMarker marker);
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/ClusteringStrategy.java import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.CameraPosition; import java.util.List; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; interface ClusteringStrategy { void cleanup(); void onCameraChange(CameraPosition cameraPosition); void onClusterGroupChange(DelegatingMarker marker); void onAdd(DelegatingMarker marker); void onRemove(DelegatingMarker marker); void onPositionChange(DelegatingMarker marker); void onVisibilityChangeRequest(DelegatingMarker marker, boolean visible); void onShowInfoWindow(DelegatingMarker marker);
Marker map(com.google.android.gms.maps.model.Marker original);
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java
// Path: app/src/main/java/com/referendum/uoctubre/UOctubreApplication.java // public class UOctubreApplication extends Application { // // private static UOctubreApplication sInstance; // // @Override // public void onCreate() { // super.onCreate(); // // sInstance = this; // // Fabric.with(this, new Crashlytics()); // // StringsManager.initialize(); // // TwitterConfig config = new TwitterConfig.Builder(this) // .logger(new DefaultLogger(Log.DEBUG)) // .twitterAuthConfig(new TwitterAuthConfig(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET)) // .debug(true) // .build(); // Twitter.initialize(config); // // //Create Notification channel in Android O // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // if (notificationManager != null) { // NotificationChannel mChannel = new NotificationChannel("referendum", // StringsManager.getString("notification_channel_name"), NotificationManager.IMPORTANCE_HIGH); // mChannel.setDescription(StringsManager.getString("notification_channel_description")); // mChannel.enableLights(true); // mChannel.setLightColor(Color.RED); // notificationManager.createNotificationChannel(mChannel); // } // } // } // // public static UOctubreApplication getInstance() { // return sInstance; // } // }
import android.content.res.Resources; import android.util.Log; import android.util.Xml; import com.crashlytics.android.Crashlytics; import com.referendum.uoctubre.UOctubreApplication; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.IllegalFormatException;
mStrings = new HashMap<>(); refreshLiterals(); } public static String getString(String id, Object... args) { synchronized (lock) { if (mStrings.containsKey(id)) { try { return String.format(mStrings.get(id).toString(), args); } catch (IllegalFormatException e) { Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); return mStrings.get(id).toString(); } } else { Crashlytics.logException(new RuntimeException("String not found: " + id)); return ""; } } } private static void refreshLiterals() { synchronized (lock) { mStrings.clear(); loadStringsFromResourceFile(); } } private static void loadStringsFromResourceFile() { try {
// Path: app/src/main/java/com/referendum/uoctubre/UOctubreApplication.java // public class UOctubreApplication extends Application { // // private static UOctubreApplication sInstance; // // @Override // public void onCreate() { // super.onCreate(); // // sInstance = this; // // Fabric.with(this, new Crashlytics()); // // StringsManager.initialize(); // // TwitterConfig config = new TwitterConfig.Builder(this) // .logger(new DefaultLogger(Log.DEBUG)) // .twitterAuthConfig(new TwitterAuthConfig(Constants.TWITTER_CONSUMER_KEY, Constants.TWITTER_CONSUMER_SECRET)) // .debug(true) // .build(); // Twitter.initialize(config); // // //Create Notification channel in Android O // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { // NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // if (notificationManager != null) { // NotificationChannel mChannel = new NotificationChannel("referendum", // StringsManager.getString("notification_channel_name"), NotificationManager.IMPORTANCE_HIGH); // mChannel.setDescription(StringsManager.getString("notification_channel_description")); // mChannel.enableLights(true); // mChannel.setLightColor(Color.RED); // notificationManager.createNotificationChannel(mChannel); // } // } // } // // public static UOctubreApplication getInstance() { // return sInstance; // } // } // Path: app/src/main/java/com/referendum/uoctubre/utils/StringsManager.java import android.content.res.Resources; import android.util.Log; import android.util.Xml; import com.crashlytics.android.Crashlytics; import com.referendum.uoctubre.UOctubreApplication; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.IllegalFormatException; mStrings = new HashMap<>(); refreshLiterals(); } public static String getString(String id, Object... args) { synchronized (lock) { if (mStrings.containsKey(id)) { try { return String.format(mStrings.get(id).toString(), args); } catch (IllegalFormatException e) { Log.e(TAG, "A string was found with wrong format parameters! The string is: " + id); return mStrings.get(id).toString(); } } else { Crashlytics.logException(new RuntimeException("String not found: " + id)); return ""; } } } private static void refreshLiterals() { synchronized (lock) { mStrings.clear(); loadStringsFromResourceFile(); } } private static void loadStringsFromResourceFile() { try {
Resources res = UOctubreApplication.getInstance().getResources();
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolygonManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolygonClickListener { // // void onPolygonClick(Polygon polygon); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polygon.java // public interface Polygon { // // <T> T getData(); // // int getFillColor(); // // List<List<LatLng>> getHoles(); // // @Deprecated // String getId(); // // List<LatLng> getPoints(); // // int getStrokeColor(); // // int getStrokeJointType(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setGeodesic(boolean geodesic); // // void setHoles(List<? extends List<LatLng>> holes); // // void setPoints(List<LatLng> points); // // void setStrokeColor(int strokeColor); // // void setStrokeJointType(int strokeJointType); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolygonOptions.java // public class PolygonOptions { // // public final com.google.android.gms.maps.model.PolygonOptions real = new com.google.android.gms.maps.model.PolygonOptions(); // private Object data; // // public PolygonOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolygonOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolygonOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolygonOptions addHole(Iterable<LatLng> points) { // real.addHole(points); // return this; // } // // public PolygonOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolygonOptions data(Object data) { // this.data = data; // return this; // } // // public PolygonOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public PolygonOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public List<List<LatLng>> getHoles() { // return real.getHoles(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public int getStrokeJointType() { // return real.getStrokeJointType(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolygonOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public PolygonOptions strokeJointType(int type) { // real.strokeJointType(type); // return this; // } // // public PolygonOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public PolygonOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public PolygonOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolygonOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.GoogleMap.OnPolygonClickListener; import com.androidmapsextensions.Polygon; import com.androidmapsextensions.PolygonOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolygonManager { private final IGoogleMap factory;
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolygonClickListener { // // void onPolygonClick(Polygon polygon); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polygon.java // public interface Polygon { // // <T> T getData(); // // int getFillColor(); // // List<List<LatLng>> getHoles(); // // @Deprecated // String getId(); // // List<LatLng> getPoints(); // // int getStrokeColor(); // // int getStrokeJointType(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setGeodesic(boolean geodesic); // // void setHoles(List<? extends List<LatLng>> holes); // // void setPoints(List<LatLng> points); // // void setStrokeColor(int strokeColor); // // void setStrokeJointType(int strokeJointType); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolygonOptions.java // public class PolygonOptions { // // public final com.google.android.gms.maps.model.PolygonOptions real = new com.google.android.gms.maps.model.PolygonOptions(); // private Object data; // // public PolygonOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolygonOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolygonOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolygonOptions addHole(Iterable<LatLng> points) { // real.addHole(points); // return this; // } // // public PolygonOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolygonOptions data(Object data) { // this.data = data; // return this; // } // // public PolygonOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public PolygonOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public List<List<LatLng>> getHoles() { // return real.getHoles(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public int getStrokeJointType() { // return real.getStrokeJointType(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolygonOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public PolygonOptions strokeJointType(int type) { // real.strokeJointType(type); // return this; // } // // public PolygonOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public PolygonOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public PolygonOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolygonOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolygonManager.java import com.androidmapsextensions.GoogleMap.OnPolygonClickListener; import com.androidmapsextensions.Polygon; import com.androidmapsextensions.PolygonOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolygonManager { private final IGoogleMap factory;
private final Map<com.google.android.gms.maps.model.Polygon, Polygon> polygons;
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolygonManager.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolygonClickListener { // // void onPolygonClick(Polygon polygon); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polygon.java // public interface Polygon { // // <T> T getData(); // // int getFillColor(); // // List<List<LatLng>> getHoles(); // // @Deprecated // String getId(); // // List<LatLng> getPoints(); // // int getStrokeColor(); // // int getStrokeJointType(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setGeodesic(boolean geodesic); // // void setHoles(List<? extends List<LatLng>> holes); // // void setPoints(List<LatLng> points); // // void setStrokeColor(int strokeColor); // // void setStrokeJointType(int strokeJointType); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolygonOptions.java // public class PolygonOptions { // // public final com.google.android.gms.maps.model.PolygonOptions real = new com.google.android.gms.maps.model.PolygonOptions(); // private Object data; // // public PolygonOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolygonOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolygonOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolygonOptions addHole(Iterable<LatLng> points) { // real.addHole(points); // return this; // } // // public PolygonOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolygonOptions data(Object data) { // this.data = data; // return this; // } // // public PolygonOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public PolygonOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public List<List<LatLng>> getHoles() { // return real.getHoles(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public int getStrokeJointType() { // return real.getStrokeJointType(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolygonOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public PolygonOptions strokeJointType(int type) { // real.strokeJointType(type); // return this; // } // // public PolygonOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public PolygonOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public PolygonOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolygonOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // }
import com.androidmapsextensions.GoogleMap.OnPolygonClickListener; import com.androidmapsextensions.Polygon; import com.androidmapsextensions.PolygonOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
/* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolygonManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Polygon, Polygon> polygons; public PolygonManager(IGoogleMap factory) { this.factory = factory; this.polygons = new HashMap<>(); }
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/GoogleMap.java // interface OnPolygonClickListener { // // void onPolygonClick(Polygon polygon); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Polygon.java // public interface Polygon { // // <T> T getData(); // // int getFillColor(); // // List<List<LatLng>> getHoles(); // // @Deprecated // String getId(); // // List<LatLng> getPoints(); // // int getStrokeColor(); // // int getStrokeJointType(); // // List<PatternItem> getStrokePattern(); // // float getStrokeWidth(); // // Object getTag(); // // float getZIndex(); // // boolean isClickable(); // // boolean isGeodesic(); // // boolean isVisible(); // // void remove(); // // void setClickable(boolean clickable); // // void setData(Object data); // // void setFillColor(int fillColor); // // void setGeodesic(boolean geodesic); // // void setHoles(List<? extends List<LatLng>> holes); // // void setPoints(List<LatLng> points); // // void setStrokeColor(int strokeColor); // // void setStrokeJointType(int strokeJointType); // // void setStrokePattern(List<PatternItem> strokePattern); // // void setStrokeWidth(float strokeWidth); // // void setTag(Object tag); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/PolygonOptions.java // public class PolygonOptions { // // public final com.google.android.gms.maps.model.PolygonOptions real = new com.google.android.gms.maps.model.PolygonOptions(); // private Object data; // // public PolygonOptions add(LatLng point) { // real.add(point); // return this; // } // // public PolygonOptions add(LatLng... points) { // real.add(points); // return this; // } // // public PolygonOptions addAll(Iterable<LatLng> points) { // real.addAll(points); // return this; // } // // public PolygonOptions addHole(Iterable<LatLng> points) { // real.addHole(points); // return this; // } // // public PolygonOptions clickable(boolean clickable) { // real.clickable(clickable); // return this; // } // // public PolygonOptions data(Object data) { // this.data = data; // return this; // } // // public PolygonOptions fillColor(int color) { // real.fillColor(color); // return this; // } // // public PolygonOptions geodesic(boolean geodesic) { // real.geodesic(geodesic); // return this; // } // // public Object getData() { // return data; // } // // public int getFillColor() { // return real.getFillColor(); // } // // public List<List<LatLng>> getHoles() { // return real.getHoles(); // } // // public List<LatLng> getPoints() { // return real.getPoints(); // } // // public int getStrokeColor() { // return real.getStrokeColor(); // } // // public int getStrokeJointType() { // return real.getStrokeJointType(); // } // // public List<PatternItem> getStrokePattern() { // return real.getStrokePattern(); // } // // public float getStrokeWidth() { // return real.getStrokeWidth(); // } // // public float getZIndex() { // return real.getZIndex(); // } // // public boolean isClickable() { // return real.isClickable(); // } // // public boolean isGeodesic() { // return real.isGeodesic(); // } // // public boolean isVisible() { // return real.isVisible(); // } // // public PolygonOptions strokeColor(int color) { // real.strokeColor(color); // return this; // } // // public PolygonOptions strokeJointType(int type) { // real.strokeJointType(type); // return this; // } // // public PolygonOptions strokePattern(List<PatternItem> pattern) { // real.strokePattern(pattern); // return this; // } // // public PolygonOptions strokeWidth(float width) { // real.strokeWidth(width); // return this; // } // // public PolygonOptions visible(boolean visible) { // real.visible(visible); // return this; // } // // public PolygonOptions zIndex(float zIndex) { // real.zIndex(zIndex); // return this; // } // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/PolygonManager.java import com.androidmapsextensions.GoogleMap.OnPolygonClickListener; import com.androidmapsextensions.Polygon; import com.androidmapsextensions.PolygonOptions; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* * Copyright (C) 2013 Maciej Górski * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.androidmapsextensions.impl; class PolygonManager { private final IGoogleMap factory; private final Map<com.google.android.gms.maps.model.Polygon, Polygon> polygons; public PolygonManager(IGoogleMap factory) { this.factory = factory; this.polygons = new HashMap<>(); }
public Polygon addPolygon(PolygonOptions polygonOptions) {
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/adapters/ImageAdapter.java
// Path: app/src/main/java/com/referendum/uoctubre/model/Image.java // public class Image implements Serializable { // private String name; // private String url; // private int order; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public int getOrder() { // return order; // } // // public void setOrder(int order) { // this.order = order; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/utils/GenericRecyclerViewViewHolder.java // public class GenericRecyclerViewViewHolder extends RecyclerView.ViewHolder { // private Hashtable<String, View> holder = new Hashtable<>(); // // public GenericRecyclerViewViewHolder(View itemView) { // super(itemView); // } // // public void setView(String k, View v) { // holder.put(k, v); // } // // public View getView(String k) { // return holder.get(k); // } // // public <T> T getView(String k, Class<T> type) { // return type.cast(getView(k)); // } // }
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.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.RequestOptions; import com.referendum.uoctubre.R; import com.referendum.uoctubre.model.Image; import com.referendum.uoctubre.utils.GenericRecyclerViewViewHolder; import java.util.List;
package com.referendum.uoctubre.adapters; public class ImageAdapter extends RecyclerView.Adapter<GenericRecyclerViewViewHolder> { private OnImageClickedListener onImageClickedListener;
// Path: app/src/main/java/com/referendum/uoctubre/model/Image.java // public class Image implements Serializable { // private String name; // private String url; // private int order; // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getUrl() { // return url; // } // // public void setUrl(String url) { // this.url = url; // } // // public int getOrder() { // return order; // } // // public void setOrder(int order) { // this.order = order; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/utils/GenericRecyclerViewViewHolder.java // public class GenericRecyclerViewViewHolder extends RecyclerView.ViewHolder { // private Hashtable<String, View> holder = new Hashtable<>(); // // public GenericRecyclerViewViewHolder(View itemView) { // super(itemView); // } // // public void setView(String k, View v) { // holder.put(k, v); // } // // public View getView(String k) { // return holder.get(k); // } // // public <T> T getView(String k, Class<T> type) { // return type.cast(getView(k)); // } // } // Path: app/src/main/java/com/referendum/uoctubre/adapters/ImageAdapter.java 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.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.request.RequestOptions; import com.referendum.uoctubre.R; import com.referendum.uoctubre.model.Image; import com.referendum.uoctubre.utils.GenericRecyclerViewViewHolder; import java.util.List; package com.referendum.uoctubre.adapters; public class ImageAdapter extends RecyclerView.Adapter<GenericRecyclerViewViewHolder> { private OnImageClickedListener onImageClickedListener;
private List<Image> imageList;
mosquitolabs/referendum_1o_android
app/src/main/java/com/referendum/uoctubre/adapters/HashtagAdapter.java
// Path: app/src/main/java/com/referendum/uoctubre/model/Hashtag.java // public class Hashtag { // private String hashtag; // private boolean userAdded; // // public Hashtag(String hashtag, boolean userAdded) { // this.hashtag = hashtag; // this.userAdded = userAdded; // } // // public String getHashtag() { // return hashtag; // } // // public void setHashtag(String hashtag) { // this.hashtag = hashtag; // } // // public boolean isUserAdded() { // return userAdded; // } // // public void setUserAdded(boolean userAdded) { // this.userAdded = userAdded; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/utils/GenericRecyclerViewViewHolder.java // public class GenericRecyclerViewViewHolder extends RecyclerView.ViewHolder { // private Hashtable<String, View> holder = new Hashtable<>(); // // public GenericRecyclerViewViewHolder(View itemView) { // super(itemView); // } // // public void setView(String k, View v) { // holder.put(k, v); // } // // public View getView(String k) { // return holder.get(k); // } // // public <T> T getView(String k, Class<T> type) { // return type.cast(getView(k)); // } // }
import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.referendum.uoctubre.R; import com.referendum.uoctubre.model.Hashtag; import com.referendum.uoctubre.utils.GenericRecyclerViewViewHolder; import java.util.List;
package com.referendum.uoctubre.adapters; public class HashtagAdapter extends RecyclerView.Adapter<GenericRecyclerViewViewHolder> { private OnHashtagRemovedListener onHashtagRemovedListener;
// Path: app/src/main/java/com/referendum/uoctubre/model/Hashtag.java // public class Hashtag { // private String hashtag; // private boolean userAdded; // // public Hashtag(String hashtag, boolean userAdded) { // this.hashtag = hashtag; // this.userAdded = userAdded; // } // // public String getHashtag() { // return hashtag; // } // // public void setHashtag(String hashtag) { // this.hashtag = hashtag; // } // // public boolean isUserAdded() { // return userAdded; // } // // public void setUserAdded(boolean userAdded) { // this.userAdded = userAdded; // } // } // // Path: app/src/main/java/com/referendum/uoctubre/utils/GenericRecyclerViewViewHolder.java // public class GenericRecyclerViewViewHolder extends RecyclerView.ViewHolder { // private Hashtable<String, View> holder = new Hashtable<>(); // // public GenericRecyclerViewViewHolder(View itemView) { // super(itemView); // } // // public void setView(String k, View v) { // holder.put(k, v); // } // // public View getView(String k) { // return holder.get(k); // } // // public <T> T getView(String k, Class<T> type) { // return type.cast(getView(k)); // } // } // Path: app/src/main/java/com/referendum/uoctubre/adapters/HashtagAdapter.java import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.referendum.uoctubre.R; import com.referendum.uoctubre.model.Hashtag; import com.referendum.uoctubre.utils.GenericRecyclerViewViewHolder; import java.util.List; package com.referendum.uoctubre.adapters; public class HashtagAdapter extends RecyclerView.Adapter<GenericRecyclerViewViewHolder> { private OnHashtagRemovedListener onHashtagRemovedListener;
private List<Hashtag> hashtagsList;
mosquitolabs/referendum_1o_android
android-maps-extensions/src/main/java/com/androidmapsextensions/impl/ClusterMarker.java
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/AnimationSettings.java // public class AnimationSettings { // // public static final long DEFAULT_DURATION = 500L; // // public static final Interpolator DEFAULT_INTERPOLATOR = new LinearInterpolator(); // // private long duration = DEFAULT_DURATION; // // private Interpolator interpolator = DEFAULT_INTERPOLATOR; // // public AnimationSettings duration(long duration) { // if (duration <= 0L) { // throw new IllegalArgumentException(); // } // this.duration = duration; // return this; // } // // public long getDuration() { // return duration; // } // // public Interpolator getInterpolator() { // return interpolator; // } // // public AnimationSettings interpolator(Interpolator interpolator) { // if (interpolator == null) { // throw new IllegalArgumentException(); // } // this.interpolator = interpolator; // return this; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof AnimationSettings)) { // return false; // } // AnimationSettings other = (AnimationSettings) o; // if (duration != other.duration) { // return false; // } // return interpolator.equals(other.interpolator); // } // // @Override // public int hashCode() { // // TODO: implement, low priority // return super.hashCode(); // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // }
import com.androidmapsextensions.AnimationSettings; import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.BitmapDescriptor; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import java.util.ArrayList; import java.util.Collections; import java.util.List;
} else if (count < strategy.getMinMarkersCount()) { return markers; } else { return Collections.singletonList(this); } } void removeVirtual() { if (virtual != null) { virtual.remove(); virtual = null; } } void cleanup() { if (virtual != null) { virtual.remove(); } } List<DelegatingMarker> getMarkersInternal() { return new ArrayList<DelegatingMarker>(markers); } @Override public void animatePosition(LatLng target) { throw new UnsupportedOperationException(); } @Override
// Path: android-maps-extensions/src/main/java/com/androidmapsextensions/AnimationSettings.java // public class AnimationSettings { // // public static final long DEFAULT_DURATION = 500L; // // public static final Interpolator DEFAULT_INTERPOLATOR = new LinearInterpolator(); // // private long duration = DEFAULT_DURATION; // // private Interpolator interpolator = DEFAULT_INTERPOLATOR; // // public AnimationSettings duration(long duration) { // if (duration <= 0L) { // throw new IllegalArgumentException(); // } // this.duration = duration; // return this; // } // // public long getDuration() { // return duration; // } // // public Interpolator getInterpolator() { // return interpolator; // } // // public AnimationSettings interpolator(Interpolator interpolator) { // if (interpolator == null) { // throw new IllegalArgumentException(); // } // this.interpolator = interpolator; // return this; // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof AnimationSettings)) { // return false; // } // AnimationSettings other = (AnimationSettings) o; // if (duration != other.duration) { // return false; // } // return interpolator.equals(other.interpolator); // } // // @Override // public int hashCode() { // // TODO: implement, low priority // return super.hashCode(); // } // } // // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/Marker.java // public interface Marker { // // interface AnimationCallback { // // enum CancelReason { // ANIMATE_POSITION, // DRAG_START, // REMOVE, // SET_POSITION, // } // // void onFinish(Marker marker); // // void onCancel(Marker marker, CancelReason reason); // } // // void animatePosition(LatLng target); // // void animatePosition(LatLng target, AnimationSettings settings); // // void animatePosition(LatLng target, AnimationCallback callback); // // void animatePosition(LatLng target, AnimationSettings settings, AnimationCallback callback); // // float getAlpha(); // // int getClusterGroup(); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // <T> T getData(); // // /** // * http://code.google.com/p/gmaps-api-issues/issues/detail?id=5101 // */ // @Deprecated // String getId(); // // /** // * @return list of markers inside cluster when isCluster() returns true, null otherwise // */ // List<Marker> getMarkers(); // // LatLng getPosition(); // // float getRotation(); // // String getSnippet(); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // Object getTag(); // // String getTitle(); // // float getZIndex(); // // void hideInfoWindow(); // // /** // * @return true if this marker groups other markers, false otherwise // */ // boolean isCluster(); // // boolean isDraggable(); // // boolean isFlat(); // // boolean isInfoWindowShown(); // // boolean isVisible(); // // void remove(); // // void setAlpha(float alpha); // // void setAnchor(float anchorU, float anchorV); // // void setClusterGroup(int clusterGroup); // // /** // * WARNING: may be changed in future API when this is fixed: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4650 // */ // void setData(Object data); // // void setDraggable(boolean draggable); // // void setFlat(boolean flat); // // void setIcon(BitmapDescriptor icon); // // void setInfoWindowAnchor(float anchorU, float anchorV); // // void setPosition(LatLng position); // // void setRotation(float rotation); // // void setSnippet(String snippet); // // /** // * Calling this method forced marker to be created via Google Maps Android API // * and disables most of the optimizations when using clustering and addMarkersDynamically method. // * Use setData instead whenever possible. // */ // @Deprecated // void setTag(Object tag); // // void setTitle(String title); // // void setVisible(boolean visible); // // void setZIndex(float zIndex); // // void showInfoWindow(); // } // Path: android-maps-extensions/src/main/java/com/androidmapsextensions/impl/ClusterMarker.java import com.androidmapsextensions.AnimationSettings; import com.androidmapsextensions.Marker; import com.google.android.gms.maps.model.BitmapDescriptor; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import java.util.ArrayList; import java.util.Collections; import java.util.List; } else if (count < strategy.getMinMarkersCount()) { return markers; } else { return Collections.singletonList(this); } } void removeVirtual() { if (virtual != null) { virtual.remove(); virtual = null; } } void cleanup() { if (virtual != null) { virtual.remove(); } } List<DelegatingMarker> getMarkersInternal() { return new ArrayList<DelegatingMarker>(markers); } @Override public void animatePosition(LatLng target) { throw new UnsupportedOperationException(); } @Override
public void animatePosition(LatLng target, AnimationSettings settings) {
UndefinedOffset/eclipse-silverstripedt
ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/modelhandler/ModelHandlerForSS.java
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/encoding/SilverStripeDocumentLoader.java // @SuppressWarnings("restriction") // public class SilverStripeDocumentLoader extends HTMLDocumentLoader { // /* // * @see IModelLoader#getParser() // */ // public RegionParser getParser() { // SSSourceParser parser = new SSSourceParser(); // // for the "static HTML" case, we need to initialize // // Blocktags here. // addHTMLishTag(parser, "script"); //$NON-NLS-1$ // addHTMLishTag(parser, "style"); //$NON-NLS-1$ // return parser; // } // }
import org.eclipse.wst.html.core.internal.modelhandler.ModelHandlerForHTML; import org.eclipse.wst.sse.core.internal.document.IDocumentLoader; import ca.edchipman.silverstripepdt.encoding.SilverStripeDocumentLoader;
package ca.edchipman.silverstripepdt.modelhandler; @SuppressWarnings("restriction") public class ModelHandlerForSS extends ModelHandlerForHTML { /** * Needs to match what's in plugin registry. * In fact, can be overwritten at run time with * what's in registry! (so should never be 'final') */ static String AssociatedContentTypeID = "ca.edchipman.silverstripepdt.SilverStripeTemplateSource"; //$NON-NLS-1$ /** * Needs to match what's in plugin registry. * In fact, can be overwritten at run time with * what's in registry! (so should never be 'final') */ private static String ModelHandlerID_SS = "ca.edchipman.silverstripepdt.modelhandler"; //$NON-NLS-1$ public ModelHandlerForSS() { super(); setId(ModelHandlerID_SS); setAssociatedContentTypeId(AssociatedContentTypeID); } public IDocumentLoader getDocumentLoader() {
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/encoding/SilverStripeDocumentLoader.java // @SuppressWarnings("restriction") // public class SilverStripeDocumentLoader extends HTMLDocumentLoader { // /* // * @see IModelLoader#getParser() // */ // public RegionParser getParser() { // SSSourceParser parser = new SSSourceParser(); // // for the "static HTML" case, we need to initialize // // Blocktags here. // addHTMLishTag(parser, "script"); //$NON-NLS-1$ // addHTMLishTag(parser, "style"); //$NON-NLS-1$ // return parser; // } // } // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/modelhandler/ModelHandlerForSS.java import org.eclipse.wst.html.core.internal.modelhandler.ModelHandlerForHTML; import org.eclipse.wst.sse.core.internal.document.IDocumentLoader; import ca.edchipman.silverstripepdt.encoding.SilverStripeDocumentLoader; package ca.edchipman.silverstripepdt.modelhandler; @SuppressWarnings("restriction") public class ModelHandlerForSS extends ModelHandlerForHTML { /** * Needs to match what's in plugin registry. * In fact, can be overwritten at run time with * what's in registry! (so should never be 'final') */ static String AssociatedContentTypeID = "ca.edchipman.silverstripepdt.SilverStripeTemplateSource"; //$NON-NLS-1$ /** * Needs to match what's in plugin registry. * In fact, can be overwritten at run time with * what's in registry! (so should never be 'final') */ private static String ModelHandlerID_SS = "ca.edchipman.silverstripepdt.modelhandler"; //$NON-NLS-1$ public ModelHandlerForSS() { super(); setId(ModelHandlerID_SS); setAssociatedContentTypeId(AssociatedContentTypeID); } public IDocumentLoader getDocumentLoader() {
return new SilverStripeDocumentLoader();
UndefinedOffset/eclipse-silverstripedt
ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/views/TasksViewer.java
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripeNature.java // public class SilverStripeNature extends ScriptNature { // public static final String ID = SilverStripePDTPlugin.PLUGIN_ID.toLowerCase() + ".SilverStripeNature"; //$NON-NLS-1$ // } // // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripePluginImages.java // public class SilverStripePluginImages { // public static final ImageDescriptor DESC_ADD_SS_FILE = create("newssfile_wiz.gif", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor DESC_NEW_SS_PROJECT = create("newssprj_wiz.png", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor IMG_REFRESH = create("refresh.gif", "actions");//$NON-NLS-1$ // // private static ImageDescriptor create(String name, String type) { // try { // return ImageDescriptor.createFromURL(makeIconFileURL(name, type)); // } catch (MalformedURLException e) { // return ImageDescriptor.getMissingImageDescriptor(); // } // } // // private static URL makeIconFileURL(String name, String type) // throws MalformedURLException { // URL fgIconBaseURL=Platform.getBundle(SilverStripePDTPlugin.PLUGIN_ID).getEntry("/icons/full/"+type+"/"); // if (fgIconBaseURL == null) // throw new MalformedURLException(); // // return new URL(fgIconBaseURL, name); // } // }
import java.lang.reflect.Array; import java.util.ArrayList; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.IField; import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.core.IScriptProject; import org.eclipse.dltk.core.IType; import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.core.index2.search.ISearchEngine.MatchRule; import org.eclipse.dltk.core.search.IDLTKSearchScope; import org.eclipse.dltk.core.search.SearchEngine; import org.eclipse.dltk.internal.ui.typehierarchy.SubTypeHierarchyViewer.SubTypeHierarchyContentProvider; import org.eclipse.dltk.internal.ui.typehierarchy.TypeHierarchyLifeCycle; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.php.internal.core.documentModel.dom.ElementImplForPHP; import org.eclipse.php.internal.core.model.PHPModelAccess; import org.eclipse.php.internal.core.preferences.CorePreferencesSupport; import org.eclipse.php.internal.core.typeinference.PHPModelUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.ProgressEvent; import org.eclipse.swt.browser.ProgressListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.custom.ScrolledComposite; import ca.edchipman.silverstripepdt.SilverStripeNature; import ca.edchipman.silverstripepdt.SilverStripePluginImages;
fTasksBrowser = null; browserInitError=true; } fErrorView = new Composite(fViewStack, SWT.NONE); fErrorView.setLayout(new GridLayout(1, false)); fErrorLabel = new Label(fErrorView, SWT.CENTER); fErrorLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1)); fErrorLabel.setAlignment(SWT.CENTER); if(browserInitError) { fErrorLabel.setText("SWT Browser control is not available. Please refer to: http://www.eclipse.org/swt/faq.php#whatisbrowser for more information."); }else { fErrorLabel.setText("No project is selected"); } ControlDecoration controlDecoration = new ControlDecoration(fErrorLabel, SWT.LEFT | SWT.TOP); controlDecoration.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); createActions(); initializeToolBar(); //Find the current project IResource currentSelection=extractSelection(getSite().getWorkbenchWindow().getSelectionService().getSelection()); if(currentSelection!=null) { IProject project=currentSelection.getProject(); try {
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripeNature.java // public class SilverStripeNature extends ScriptNature { // public static final String ID = SilverStripePDTPlugin.PLUGIN_ID.toLowerCase() + ".SilverStripeNature"; //$NON-NLS-1$ // } // // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripePluginImages.java // public class SilverStripePluginImages { // public static final ImageDescriptor DESC_ADD_SS_FILE = create("newssfile_wiz.gif", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor DESC_NEW_SS_PROJECT = create("newssprj_wiz.png", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor IMG_REFRESH = create("refresh.gif", "actions");//$NON-NLS-1$ // // private static ImageDescriptor create(String name, String type) { // try { // return ImageDescriptor.createFromURL(makeIconFileURL(name, type)); // } catch (MalformedURLException e) { // return ImageDescriptor.getMissingImageDescriptor(); // } // } // // private static URL makeIconFileURL(String name, String type) // throws MalformedURLException { // URL fgIconBaseURL=Platform.getBundle(SilverStripePDTPlugin.PLUGIN_ID).getEntry("/icons/full/"+type+"/"); // if (fgIconBaseURL == null) // throw new MalformedURLException(); // // return new URL(fgIconBaseURL, name); // } // } // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/views/TasksViewer.java import java.lang.reflect.Array; import java.util.ArrayList; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.IField; import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.core.IScriptProject; import org.eclipse.dltk.core.IType; import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.core.index2.search.ISearchEngine.MatchRule; import org.eclipse.dltk.core.search.IDLTKSearchScope; import org.eclipse.dltk.core.search.SearchEngine; import org.eclipse.dltk.internal.ui.typehierarchy.SubTypeHierarchyViewer.SubTypeHierarchyContentProvider; import org.eclipse.dltk.internal.ui.typehierarchy.TypeHierarchyLifeCycle; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.php.internal.core.documentModel.dom.ElementImplForPHP; import org.eclipse.php.internal.core.model.PHPModelAccess; import org.eclipse.php.internal.core.preferences.CorePreferencesSupport; import org.eclipse.php.internal.core.typeinference.PHPModelUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.ProgressEvent; import org.eclipse.swt.browser.ProgressListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.custom.ScrolledComposite; import ca.edchipman.silverstripepdt.SilverStripeNature; import ca.edchipman.silverstripepdt.SilverStripePluginImages; fTasksBrowser = null; browserInitError=true; } fErrorView = new Composite(fViewStack, SWT.NONE); fErrorView.setLayout(new GridLayout(1, false)); fErrorLabel = new Label(fErrorView, SWT.CENTER); fErrorLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1)); fErrorLabel.setAlignment(SWT.CENTER); if(browserInitError) { fErrorLabel.setText("SWT Browser control is not available. Please refer to: http://www.eclipse.org/swt/faq.php#whatisbrowser for more information."); }else { fErrorLabel.setText("No project is selected"); } ControlDecoration controlDecoration = new ControlDecoration(fErrorLabel, SWT.LEFT | SWT.TOP); controlDecoration.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK)); createActions(); initializeToolBar(); //Find the current project IResource currentSelection=extractSelection(getSite().getWorkbenchWindow().getSelectionService().getSelection()); if(currentSelection!=null) { IProject project=currentSelection.getProject(); try {
if(project.hasNature(SilverStripeNature.ID)) {
UndefinedOffset/eclipse-silverstripedt
ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/views/TasksViewer.java
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripeNature.java // public class SilverStripeNature extends ScriptNature { // public static final String ID = SilverStripePDTPlugin.PLUGIN_ID.toLowerCase() + ".SilverStripeNature"; //$NON-NLS-1$ // } // // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripePluginImages.java // public class SilverStripePluginImages { // public static final ImageDescriptor DESC_ADD_SS_FILE = create("newssfile_wiz.gif", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor DESC_NEW_SS_PROJECT = create("newssprj_wiz.png", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor IMG_REFRESH = create("refresh.gif", "actions");//$NON-NLS-1$ // // private static ImageDescriptor create(String name, String type) { // try { // return ImageDescriptor.createFromURL(makeIconFileURL(name, type)); // } catch (MalformedURLException e) { // return ImageDescriptor.getMissingImageDescriptor(); // } // } // // private static URL makeIconFileURL(String name, String type) // throws MalformedURLException { // URL fgIconBaseURL=Platform.getBundle(SilverStripePDTPlugin.PLUGIN_ID).getEntry("/icons/full/"+type+"/"); // if (fgIconBaseURL == null) // throw new MalformedURLException(); // // return new URL(fgIconBaseURL, name); // } // }
import java.lang.reflect.Array; import java.util.ArrayList; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.IField; import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.core.IScriptProject; import org.eclipse.dltk.core.IType; import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.core.index2.search.ISearchEngine.MatchRule; import org.eclipse.dltk.core.search.IDLTKSearchScope; import org.eclipse.dltk.core.search.SearchEngine; import org.eclipse.dltk.internal.ui.typehierarchy.SubTypeHierarchyViewer.SubTypeHierarchyContentProvider; import org.eclipse.dltk.internal.ui.typehierarchy.TypeHierarchyLifeCycle; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.php.internal.core.documentModel.dom.ElementImplForPHP; import org.eclipse.php.internal.core.model.PHPModelAccess; import org.eclipse.php.internal.core.preferences.CorePreferencesSupport; import org.eclipse.php.internal.core.typeinference.PHPModelUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.ProgressEvent; import org.eclipse.swt.browser.ProgressListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.custom.ScrolledComposite; import ca.edchipman.silverstripepdt.SilverStripeNature; import ca.edchipman.silverstripepdt.SilverStripePluginImages;
@Override public void partOpened(IWorkbenchPartReference partRef) {} @Override public void partInputChanged(IWorkbenchPartReference partRef) {} @Override public void partHidden(IWorkbenchPartReference partRef) {} @Override public void partDeactivated(IWorkbenchPartReference partRef) {} @Override public void partClosed(IWorkbenchPartReference partRef) {} @Override public void partBroughtToTop(IWorkbenchPartReference partRef) {} @Override public void partActivated(IWorkbenchPartReference partRef) {} }; private class RefreshAction extends Action { private TasksViewer tasksViewer; public RefreshAction(TasksViewer _tasksViewer) { this.tasksViewer=_tasksViewer; this.setText("Refresh"); this.setDescription("Refresh Tasks List");
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripeNature.java // public class SilverStripeNature extends ScriptNature { // public static final String ID = SilverStripePDTPlugin.PLUGIN_ID.toLowerCase() + ".SilverStripeNature"; //$NON-NLS-1$ // } // // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripePluginImages.java // public class SilverStripePluginImages { // public static final ImageDescriptor DESC_ADD_SS_FILE = create("newssfile_wiz.gif", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor DESC_NEW_SS_PROJECT = create("newssprj_wiz.png", "wizban");//$NON-NLS-1$ // public static final ImageDescriptor IMG_REFRESH = create("refresh.gif", "actions");//$NON-NLS-1$ // // private static ImageDescriptor create(String name, String type) { // try { // return ImageDescriptor.createFromURL(makeIconFileURL(name, type)); // } catch (MalformedURLException e) { // return ImageDescriptor.getMissingImageDescriptor(); // } // } // // private static URL makeIconFileURL(String name, String type) // throws MalformedURLException { // URL fgIconBaseURL=Platform.getBundle(SilverStripePDTPlugin.PLUGIN_ID).getEntry("/icons/full/"+type+"/"); // if (fgIconBaseURL == null) // throw new MalformedURLException(); // // return new URL(fgIconBaseURL, name); // } // } // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/views/TasksViewer.java import java.lang.reflect.Array; import java.util.ArrayList; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.dltk.core.DLTKCore; import org.eclipse.dltk.core.IField; import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.core.IScriptProject; import org.eclipse.dltk.core.IType; import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.core.index2.search.ISearchEngine.MatchRule; import org.eclipse.dltk.core.search.IDLTKSearchScope; import org.eclipse.dltk.core.search.SearchEngine; import org.eclipse.dltk.internal.ui.typehierarchy.SubTypeHierarchyViewer.SubTypeHierarchyContentProvider; import org.eclipse.dltk.internal.ui.typehierarchy.TypeHierarchyLifeCycle; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.resource.FontDescriptor; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.php.internal.core.documentModel.dom.ElementImplForPHP; import org.eclipse.php.internal.core.model.PHPModelAccess; import org.eclipse.php.internal.core.preferences.CorePreferencesSupport; import org.eclipse.php.internal.core.typeinference.PHPModelUtils; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPartReference; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.browser.ProgressEvent; import org.eclipse.swt.browser.ProgressListener; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.jface.fieldassist.ControlDecoration; import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.custom.ScrolledComposite; import ca.edchipman.silverstripepdt.SilverStripeNature; import ca.edchipman.silverstripepdt.SilverStripePluginImages; @Override public void partOpened(IWorkbenchPartReference partRef) {} @Override public void partInputChanged(IWorkbenchPartReference partRef) {} @Override public void partHidden(IWorkbenchPartReference partRef) {} @Override public void partDeactivated(IWorkbenchPartReference partRef) {} @Override public void partClosed(IWorkbenchPartReference partRef) {} @Override public void partBroughtToTop(IWorkbenchPartReference partRef) {} @Override public void partActivated(IWorkbenchPartReference partRef) {} }; private class RefreshAction extends Action { private TasksViewer tasksViewer; public RefreshAction(TasksViewer _tasksViewer) { this.tasksViewer=_tasksViewer; this.setText("Refresh"); this.setDescription("Refresh Tasks List");
this.setImageDescriptor(SilverStripePluginImages.IMG_REFRESH);
UndefinedOffset/eclipse-silverstripedt
ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/dialogs/FilteredTypesSelectionDialog.java
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/search/ISilverStripePDTSearchConstants.java // public interface ISilverStripePDTSearchConstants extends IDLTKSearchConstants { // public static int INTERFACE=8; // public static int CLASS=5; // }
import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.IJobManager; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.dltk.ast.Modifiers; import org.eclipse.dltk.core.Flags; import org.eclipse.dltk.core.IDLTKLanguageToolkit; import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.core.IProjectFragment; import org.eclipse.dltk.core.IType; import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.core.WorkingCopyOwner; import org.eclipse.dltk.core.index2.search.ModelAccess; import org.eclipse.dltk.core.search.IDLTKSearchConstants; import org.eclipse.dltk.core.search.IDLTKSearchScope; import org.eclipse.dltk.core.search.NopTypeNameRequestor; import org.eclipse.dltk.core.search.SearchEngine; import org.eclipse.dltk.core.search.TypeNameMatch; import org.eclipse.dltk.core.search.TypeNameMatchRequestor; import org.eclipse.dltk.internal.core.search.DLTKSearchTypeNameMatch; import org.eclipse.dltk.internal.corext.util.Messages; import org.eclipse.dltk.internal.corext.util.OpenTypeHistory; import org.eclipse.dltk.internal.corext.util.Strings; import org.eclipse.dltk.internal.corext.util.TypeFilter; import org.eclipse.dltk.internal.corext.util.TypeInfoRequestorAdapter; import org.eclipse.dltk.internal.ui.DLTKUIMessages; import org.eclipse.dltk.internal.ui.dialogs.TextFieldNavigationHandler; import org.eclipse.dltk.internal.ui.search.DLTKSearchScopeFactory; import org.eclipse.dltk.internal.ui.util.TypeNameMatchLabelProvider; import org.eclipse.dltk.internal.ui.workingsets.WorkingSetFilterActionGroup; import org.eclipse.dltk.launching.IInterpreterInstall; import org.eclipse.dltk.launching.IInterpreterInstallType; import org.eclipse.dltk.launching.LibraryLocation; import org.eclipse.dltk.launching.ScriptRuntime; import org.eclipse.dltk.ui.DLTKUILanguageManager; import org.eclipse.dltk.ui.DLTKUIPlugin; import org.eclipse.dltk.ui.IDLTKUILanguageToolkit; import org.eclipse.dltk.ui.ScriptElementImageProvider; import org.eclipse.dltk.ui.ScriptElementLabels; import org.eclipse.dltk.ui.dialogs.*; import org.eclipse.dltk.ui.util.ExceptionHandler; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProviderChangedEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IMemento; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.XMLMemento; import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog; import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.dialogs.SearchPattern; import ca.edchipman.silverstripepdt.search.ISilverStripePDTSearchConstants;
} public boolean matchesFilterExtension(TypeNameMatch type) { if (fFilterExt == null) return true; fAdapter.setMatch(type); return fFilterExt.select(fAdapter); } private boolean matchesName(TypeNameMatch type) { return matches(type.getSimpleTypeName()); } private boolean matchesPackage(TypeNameMatch type) { if (fPackageMatcher == null) return true; return fPackageMatcher.matches(type.getPackageName()); } private boolean matchesScope(TypeNameMatch type) { if (fIsWorkspaceScope) return true; return fScope.encloses(type.getType()); } private boolean matchesModifiers(TypeNameMatch type) { if (fElemKind == IDLTKSearchConstants.TYPE) return true; int modifiers = type.getModifiers() & TYPE_MODIFIERS;
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/search/ISilverStripePDTSearchConstants.java // public interface ISilverStripePDTSearchConstants extends IDLTKSearchConstants { // public static int INTERFACE=8; // public static int CLASS=5; // } // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/dialogs/FilteredTypesSelectionDialog.java import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.jobs.IJobManager; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.dltk.ast.Modifiers; import org.eclipse.dltk.core.Flags; import org.eclipse.dltk.core.IDLTKLanguageToolkit; import org.eclipse.dltk.core.IModelElement; import org.eclipse.dltk.core.IProjectFragment; import org.eclipse.dltk.core.IType; import org.eclipse.dltk.core.ModelException; import org.eclipse.dltk.core.WorkingCopyOwner; import org.eclipse.dltk.core.index2.search.ModelAccess; import org.eclipse.dltk.core.search.IDLTKSearchConstants; import org.eclipse.dltk.core.search.IDLTKSearchScope; import org.eclipse.dltk.core.search.NopTypeNameRequestor; import org.eclipse.dltk.core.search.SearchEngine; import org.eclipse.dltk.core.search.TypeNameMatch; import org.eclipse.dltk.core.search.TypeNameMatchRequestor; import org.eclipse.dltk.internal.core.search.DLTKSearchTypeNameMatch; import org.eclipse.dltk.internal.corext.util.Messages; import org.eclipse.dltk.internal.corext.util.OpenTypeHistory; import org.eclipse.dltk.internal.corext.util.Strings; import org.eclipse.dltk.internal.corext.util.TypeFilter; import org.eclipse.dltk.internal.corext.util.TypeInfoRequestorAdapter; import org.eclipse.dltk.internal.ui.DLTKUIMessages; import org.eclipse.dltk.internal.ui.dialogs.TextFieldNavigationHandler; import org.eclipse.dltk.internal.ui.search.DLTKSearchScopeFactory; import org.eclipse.dltk.internal.ui.util.TypeNameMatchLabelProvider; import org.eclipse.dltk.internal.ui.workingsets.WorkingSetFilterActionGroup; import org.eclipse.dltk.launching.IInterpreterInstall; import org.eclipse.dltk.launching.IInterpreterInstallType; import org.eclipse.dltk.launching.LibraryLocation; import org.eclipse.dltk.launching.ScriptRuntime; import org.eclipse.dltk.ui.DLTKUILanguageManager; import org.eclipse.dltk.ui.DLTKUIPlugin; import org.eclipse.dltk.ui.IDLTKUILanguageToolkit; import org.eclipse.dltk.ui.ScriptElementImageProvider; import org.eclipse.dltk.ui.ScriptElementLabels; import org.eclipse.dltk.ui.dialogs.*; import org.eclipse.dltk.ui.util.ExceptionHandler; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ILabelDecorator; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.LabelProviderChangedEvent; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IMemento; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.XMLMemento; import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog; import org.eclipse.ui.dialogs.ISelectionStatusValidator; import org.eclipse.ui.dialogs.SearchPattern; import ca.edchipman.silverstripepdt.search.ISilverStripePDTSearchConstants; } public boolean matchesFilterExtension(TypeNameMatch type) { if (fFilterExt == null) return true; fAdapter.setMatch(type); return fFilterExt.select(fAdapter); } private boolean matchesName(TypeNameMatch type) { return matches(type.getSimpleTypeName()); } private boolean matchesPackage(TypeNameMatch type) { if (fPackageMatcher == null) return true; return fPackageMatcher.matches(type.getPackageName()); } private boolean matchesScope(TypeNameMatch type) { if (fIsWorkspaceScope) return true; return fScope.encloses(type.getType()); } private boolean matchesModifiers(TypeNameMatch type) { if (fElemKind == IDLTKSearchConstants.TYPE) return true; int modifiers = type.getModifiers() & TYPE_MODIFIERS;
if (fElemKind == ISilverStripePDTSearchConstants.INTERFACE && modifiers == ISilverStripePDTSearchConstants.INTERFACE) {
UndefinedOffset/eclipse-silverstripedt
ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/language/SilverStripeVersionChangedHandler.java
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripePreferences.java // public class SilverStripePreferences { // public static final String SILVERSTRIPE_VERSION = "silverstripe_version"; // public static final String SILVERSTRIPE_FRAMEWORK_MODEL = "silverstripe_framework_model"; // public static final String SILVERSTRIPE_SITECONFIG_MODULE = "silverstripe_siteconfig_module"; // public static final String SILVERSTRIPE_REPORTS_MODULE = "silverstripe_reports_module"; // }
import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.php.internal.core.PHPCorePlugin; import org.eclipse.php.internal.core.preferences.CorePreferencesSupport; import org.eclipse.php.internal.core.preferences.IPreferencesPropagatorListener; import org.eclipse.php.internal.core.preferences.PreferencePropagatorFactory; import org.eclipse.php.internal.core.preferences.PreferencesPropagator; import org.eclipse.php.internal.core.preferences.PreferencesPropagatorEvent; import ca.edchipman.silverstripepdt.SilverStripePreferences;
HashSet<IPreferencesPropagatorListener> listeners = projectListeners.get(project); if (listeners == null) { projectAdded(project); listeners = projectListeners.get(project); } listeners.add(listener); } public void removeSilverStripeVersionChangedListener(IPreferencesPropagatorListener listener) { if (listener == null) {// this was added since when working with RSE // project model, listener was NULL return; } IProject project = listener.getProject(); HashSet<IPreferencesPropagatorListener> listeners = projectListeners.get(project); if (listeners != null) { listeners.remove(listener); } } public void projectAdded(IProject project) { if (project == null || projectListeners.get(project) != null) { return; } projectListeners.put(project, new HashSet<IPreferencesPropagatorListener>()); // register as a listener to the PP on this project PreferencesPropagatorListener listener = new PreferencesPropagatorListener(project); preferencesPropagatorListeners.put(project, listener);
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/SilverStripePreferences.java // public class SilverStripePreferences { // public static final String SILVERSTRIPE_VERSION = "silverstripe_version"; // public static final String SILVERSTRIPE_FRAMEWORK_MODEL = "silverstripe_framework_model"; // public static final String SILVERSTRIPE_SITECONFIG_MODULE = "silverstripe_siteconfig_module"; // public static final String SILVERSTRIPE_REPORTS_MODULE = "silverstripe_reports_module"; // } // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/language/SilverStripeVersionChangedHandler.java import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.core.resources.IResourceDelta; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.php.internal.core.PHPCorePlugin; import org.eclipse.php.internal.core.preferences.CorePreferencesSupport; import org.eclipse.php.internal.core.preferences.IPreferencesPropagatorListener; import org.eclipse.php.internal.core.preferences.PreferencePropagatorFactory; import org.eclipse.php.internal.core.preferences.PreferencesPropagator; import org.eclipse.php.internal.core.preferences.PreferencesPropagatorEvent; import ca.edchipman.silverstripepdt.SilverStripePreferences; HashSet<IPreferencesPropagatorListener> listeners = projectListeners.get(project); if (listeners == null) { projectAdded(project); listeners = projectListeners.get(project); } listeners.add(listener); } public void removeSilverStripeVersionChangedListener(IPreferencesPropagatorListener listener) { if (listener == null) {// this was added since when working with RSE // project model, listener was NULL return; } IProject project = listener.getProject(); HashSet<IPreferencesPropagatorListener> listeners = projectListeners.get(project); if (listeners != null) { listeners.remove(listener); } } public void projectAdded(IProject project) { if (project == null || projectListeners.get(project) != null) { return; } projectListeners.put(project, new HashSet<IPreferencesPropagatorListener>()); // register as a listener to the PP on this project PreferencesPropagatorListener listener = new PreferencesPropagatorListener(project); preferencesPropagatorListeners.put(project, listener);
preferencesPropagator.addPropagatorListener(listener, SilverStripePreferences.SILVERSTRIPE_VERSION);
UndefinedOffset/eclipse-silverstripedt
ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/encoding/SilverStripeDocumentLoader.java
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/parser/SSSourceParser.java // @SuppressWarnings("restriction") // public class SSSourceParser extends XMLSourceParser { // protected BlockTokenizer getTokenizer() { // if (fTokenizer == null) { // fTokenizer = new SSTokenizer(); // } // return fTokenizer; // } // }
import org.eclipse.wst.html.core.internal.encoding.HTMLDocumentLoader; import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser; import ca.edchipman.silverstripepdt.parser.SSSourceParser;
package ca.edchipman.silverstripepdt.encoding; @SuppressWarnings("restriction") public class SilverStripeDocumentLoader extends HTMLDocumentLoader { /* * @see IModelLoader#getParser() */ public RegionParser getParser() {
// Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/parser/SSSourceParser.java // @SuppressWarnings("restriction") // public class SSSourceParser extends XMLSourceParser { // protected BlockTokenizer getTokenizer() { // if (fTokenizer == null) { // fTokenizer = new SSTokenizer(); // } // return fTokenizer; // } // } // Path: ca.edchipman.silverStripePDT/src/ca/edchipman/silverstripepdt/encoding/SilverStripeDocumentLoader.java import org.eclipse.wst.html.core.internal.encoding.HTMLDocumentLoader; import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser; import ca.edchipman.silverstripepdt.parser.SSSourceParser; package ca.edchipman.silverstripepdt.encoding; @SuppressWarnings("restriction") public class SilverStripeDocumentLoader extends HTMLDocumentLoader { /* * @see IModelLoader#getParser() */ public RegionParser getParser() {
SSSourceParser parser = new SSSourceParser();
ozwolf-software/raml-mock-server
src/test/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecificationTest.java
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java // public interface BodySpecification { // MediaType getContentType(); // // ValidationErrors validate(String body); // }
import net.ozwolf.mockserver.raml.internal.domain.BodySpecification; import org.junit.Test; import javax.ws.rs.core.MediaType; import static org.assertj.core.api.Assertions.assertThat;
package net.ozwolf.mockserver.raml.internal.domain.body; public class DefaultBodySpecificationTest { private final MediaType mediaType = MediaType.APPLICATION_JSON_TYPE; @Test public void shouldAlwaysReturnEmptyErrors() {
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java // public interface BodySpecification { // MediaType getContentType(); // // ValidationErrors validate(String body); // } // Path: src/test/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecificationTest.java import net.ozwolf.mockserver.raml.internal.domain.BodySpecification; import org.junit.Test; import javax.ws.rs.core.MediaType; import static org.assertj.core.api.Assertions.assertThat; package net.ozwolf.mockserver.raml.internal.domain.body; public class DefaultBodySpecificationTest { private final MediaType mediaType = MediaType.APPLICATION_JSON_TYPE; @Test public void shouldAlwaysReturnEmptyErrors() {
BodySpecification specification = new DefaultBodySpecification(mediaType);
ozwolf-software/raml-mock-server
src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap;
UriTemplateComponent component = e.getKey(); String value = e.getValue(); if (component instanceof Literal) { return StringUtils.replace(component.getValue(), "/", "").equals(value); } else { return parameters.containsKey(component.getValue()); } }); } public Optional<Header> getRequestHeader(String name) { return request.getHeaders().stream() .filter(h -> h.getName().getValue().equals(name)) .findFirst(); } public Optional<Header> getResponseHeader(String name) { return response.getHeaders().stream() .filter(h -> h.getName().getValue().equals(name)) .findFirst(); } public Optional<Parameter> getQueryParameter(String name) { return request.getQueryStringParameters().stream() .filter(p -> p.getName().getValue().equals(name)) .findFirst(); } public String getUriValueOf(String parameterName) {
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; UriTemplateComponent component = e.getKey(); String value = e.getValue(); if (component instanceof Literal) { return StringUtils.replace(component.getValue(), "/", "").equals(value); } else { return parameters.containsKey(component.getValue()); } }); } public Optional<Header> getRequestHeader(String name) { return request.getHeaders().stream() .filter(h -> h.getName().getValue().equals(name)) .findFirst(); } public Optional<Header> getResponseHeader(String name) { return response.getHeaders().stream() .filter(h -> h.getName().getValue().equals(name)) .findFirst(); } public Optional<Parameter> getQueryParameter(String name) { return request.getQueryStringParameters().stream() .filter(p -> p.getName().getValue().equals(name)) .findFirst(); } public String getUriValueOf(String parameterName) {
String uri = getResource().orElseThrow(() -> new NoValidResourceException(this)).getUri();
ozwolf-software/raml-mock-server
src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap;
public Optional<String> getResponseBody() { return Optional.of(response.getBodyAsString()); } public MediaType getRequestContentType() { return MediaType.valueOf( getRequestHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public MediaType getResponseContentType() { return MediaType.valueOf( getResponseHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public Optional<BodySpecification> getRequestBodySpecification() { Optional<MimeType> body = specification.getRequestBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType()))
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; public Optional<String> getResponseBody() { return Optional.of(response.getBodyAsString()); } public MediaType getRequestContentType() { return MediaType.valueOf( getRequestHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public MediaType getResponseContentType() { return MediaType.valueOf( getResponseHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public Optional<BodySpecification> getRequestBodySpecification() { Optional<MimeType> body = specification.getRequestBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType()))
return Optional.of(new JsonBodySpecification("request", body.get()));
ozwolf-software/raml-mock-server
src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap;
return Optional.of(response.getBodyAsString()); } public MediaType getRequestContentType() { return MediaType.valueOf( getRequestHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public MediaType getResponseContentType() { return MediaType.valueOf( getResponseHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public Optional<BodySpecification> getRequestBodySpecification() { Optional<MimeType> body = specification.getRequestBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType())) return Optional.of(new JsonBodySpecification("request", body.get()));
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; return Optional.of(response.getBodyAsString()); } public MediaType getRequestContentType() { return MediaType.valueOf( getRequestHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public MediaType getResponseContentType() { return MediaType.valueOf( getResponseHeader(HttpHeaders.CONTENT_TYPE) .orElse(new Header(HttpHeaders.CONTENT_TYPE, MediaType.WILDCARD)) .getValues() .get(0) .getValue() ); } public Optional<BodySpecification> getRequestBodySpecification() { Optional<MimeType> body = specification.getRequestBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType())) return Optional.of(new JsonBodySpecification("request", body.get()));
return Optional.of(new DefaultBodySpecification(this.getResponseContentType()));
ozwolf-software/raml-mock-server
src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap;
.getValue() ); } public Optional<BodySpecification> getRequestBodySpecification() { Optional<MimeType> body = specification.getRequestBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType())) return Optional.of(new JsonBodySpecification("request", body.get())); return Optional.of(new DefaultBodySpecification(this.getResponseContentType())); } public Optional<BodySpecification> getResponseBodySpecification() { Optional<MimeType> body = specification.getResponseBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getResponseContentType())) return Optional.of(new JsonBodySpecification("response", body.get())); return Optional.of(new DefaultBodySpecification(this.getResponseContentType())); } public Map<String, SecurityScheme> getSecuritySpecification() { List<SecurityReference> resourceReferences = getResource() .orElseThrow(() -> new NoValidResourceException(this)) .getSecuredBy(); List<SecurityReference> actionReferences = getAction()
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectation.java import com.damnhandy.uri.template.Literal; import com.damnhandy.uri.template.UriTemplateComponent; import com.damnhandy.uri.template.impl.UriTemplateParser; import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.apache.commons.lang.StringUtils; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.HttpRequest; import org.mockserver.model.HttpResponse; import org.mockserver.model.Parameter; import org.raml.model.*; import org.raml.model.parameter.UriParameter; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.*; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; .getValue() ); } public Optional<BodySpecification> getRequestBodySpecification() { Optional<MimeType> body = specification.getRequestBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getRequestContentType())) return Optional.of(new JsonBodySpecification("request", body.get())); return Optional.of(new DefaultBodySpecification(this.getResponseContentType())); } public Optional<BodySpecification> getResponseBodySpecification() { Optional<MimeType> body = specification.getResponseBodyFor(this); if (!body.isPresent()) return Optional.empty(); if (MediaType.APPLICATION_JSON_TYPE.isCompatible(this.getResponseContentType())) return Optional.of(new JsonBodySpecification("response", body.get())); return Optional.of(new DefaultBodySpecification(this.getResponseContentType())); } public Map<String, SecurityScheme> getSecuritySpecification() { List<SecurityReference> resourceReferences = getResource() .orElseThrow(() -> new NoValidResourceException(this)) .getSecuredBy(); List<SecurityReference> actionReferences = getAction()
.orElseThrow(() -> new NoValidActionException(this))
ozwolf-software/raml-mock-server
src/main/java/net/ozwolf/mockserver/raml/internal/validator/body/content/JsonContentValidator.java
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java // public class ValidationErrors { // private final List<String> messages; // // public ValidationErrors() { // this.messages = newArrayList(); // } // // public void addMessage(String error, Object... formattedParameters) { // this.messages.add(String.format(error, formattedParameters)); // } // // public void combineWith(ValidationErrors errors) { // this.messages.addAll(errors.getMessages()); // } // // public boolean isInError() { // return !this.messages.isEmpty(); // } // // public List<String> getMessages() { // return messages; // } // }
import com.fasterxml.jackson.databind.JsonNode; import com.github.fge.jackson.JsonLoader; import com.github.fge.jsonschema.core.report.ProcessingReport; import com.github.fge.jsonschema.main.JsonSchemaFactory; import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors;
package net.ozwolf.mockserver.raml.internal.validator.body.content; public class JsonContentValidator { private final String bodyType; public JsonContentValidator(String bodyType) { this.bodyType = bodyType; }
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java // public class ValidationErrors { // private final List<String> messages; // // public ValidationErrors() { // this.messages = newArrayList(); // } // // public void addMessage(String error, Object... formattedParameters) { // this.messages.add(String.format(error, formattedParameters)); // } // // public void combineWith(ValidationErrors errors) { // this.messages.addAll(errors.getMessages()); // } // // public boolean isInError() { // return !this.messages.isEmpty(); // } // // public List<String> getMessages() { // return messages; // } // } // Path: src/main/java/net/ozwolf/mockserver/raml/internal/validator/body/content/JsonContentValidator.java import com.fasterxml.jackson.databind.JsonNode; import com.github.fge.jackson.JsonLoader; import com.github.fge.jsonschema.core.report.ProcessingReport; import com.github.fge.jsonschema.main.JsonSchemaFactory; import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors; package net.ozwolf.mockserver.raml.internal.validator.body.content; public class JsonContentValidator { private final String bodyType; public JsonContentValidator(String bodyType) { this.bodyType = bodyType; }
public ValidationErrors validate(String schema, String requestBody) {
ozwolf-software/raml-mock-server
src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response;
.contains(NottableString.string("30s")); } @Test public void shouldReturnMatchingQueryParameter() { assertThat(GET_EXPECTATION.getQueryParameter("wrong").isPresent()).isFalse(); assertThat(GET_EXPECTATION.getQueryParameter("ttl").isPresent()).isTrue(); assertThat(GET_EXPECTATION.getQueryParameter("ttl").get().getValues()) .hasSize(1) .contains(NottableString.string("30s")); } @Test public void shouldReturnUriParameterValue() { assertThat(GET_EXPECTATION.getUriValueOf("name")).isEqualTo("John"); } @Test public void shouldReturnRequestContentType() { assertThat(GET_EXPECTATION.getRequestContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnResponseContentType() { assertThat(GET_EXPECTATION.getResponseContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnValidResponseBodySpecification() { assertThat(GET_EXPECTATION.getResponseBodySpecification().isPresent()).isTrue();
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; .contains(NottableString.string("30s")); } @Test public void shouldReturnMatchingQueryParameter() { assertThat(GET_EXPECTATION.getQueryParameter("wrong").isPresent()).isFalse(); assertThat(GET_EXPECTATION.getQueryParameter("ttl").isPresent()).isTrue(); assertThat(GET_EXPECTATION.getQueryParameter("ttl").get().getValues()) .hasSize(1) .contains(NottableString.string("30s")); } @Test public void shouldReturnUriParameterValue() { assertThat(GET_EXPECTATION.getUriValueOf("name")).isEqualTo("John"); } @Test public void shouldReturnRequestContentType() { assertThat(GET_EXPECTATION.getRequestContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnResponseContentType() { assertThat(GET_EXPECTATION.getResponseContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnValidResponseBodySpecification() { assertThat(GET_EXPECTATION.getResponseBodySpecification().isPresent()).isTrue();
assertThat(GET_EXPECTATION.getResponseBodySpecification().get()).isInstanceOf(JsonBodySpecification.class);
ozwolf-software/raml-mock-server
src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response;
assertThat(GET_EXPECTATION.getQueryParameter("ttl").isPresent()).isTrue(); assertThat(GET_EXPECTATION.getQueryParameter("ttl").get().getValues()) .hasSize(1) .contains(NottableString.string("30s")); } @Test public void shouldReturnUriParameterValue() { assertThat(GET_EXPECTATION.getUriValueOf("name")).isEqualTo("John"); } @Test public void shouldReturnRequestContentType() { assertThat(GET_EXPECTATION.getRequestContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnResponseContentType() { assertThat(GET_EXPECTATION.getResponseContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnValidResponseBodySpecification() { assertThat(GET_EXPECTATION.getResponseBodySpecification().isPresent()).isTrue(); assertThat(GET_EXPECTATION.getResponseBodySpecification().get()).isInstanceOf(JsonBodySpecification.class); } @Test public void shouldReturnValidRequestBodySpecification() { assertThat(PUT_EXPECTATION.getRequestBodySpecification().isPresent()).isTrue();
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; assertThat(GET_EXPECTATION.getQueryParameter("ttl").isPresent()).isTrue(); assertThat(GET_EXPECTATION.getQueryParameter("ttl").get().getValues()) .hasSize(1) .contains(NottableString.string("30s")); } @Test public void shouldReturnUriParameterValue() { assertThat(GET_EXPECTATION.getUriValueOf("name")).isEqualTo("John"); } @Test public void shouldReturnRequestContentType() { assertThat(GET_EXPECTATION.getRequestContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnResponseContentType() { assertThat(GET_EXPECTATION.getResponseContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnValidResponseBodySpecification() { assertThat(GET_EXPECTATION.getResponseBodySpecification().isPresent()).isTrue(); assertThat(GET_EXPECTATION.getResponseBodySpecification().get()).isInstanceOf(JsonBodySpecification.class); } @Test public void shouldReturnValidRequestBodySpecification() { assertThat(PUT_EXPECTATION.getRequestBodySpecification().isPresent()).isTrue();
assertThat(PUT_EXPECTATION.getRequestBodySpecification().get()).isInstanceOf(DefaultBodySpecification.class);
ozwolf-software/raml-mock-server
src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response;
public void shouldReturnRequestContentType() { assertThat(GET_EXPECTATION.getRequestContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnResponseContentType() { assertThat(GET_EXPECTATION.getResponseContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnValidResponseBodySpecification() { assertThat(GET_EXPECTATION.getResponseBodySpecification().isPresent()).isTrue(); assertThat(GET_EXPECTATION.getResponseBodySpecification().get()).isInstanceOf(JsonBodySpecification.class); } @Test public void shouldReturnValidRequestBodySpecification() { assertThat(PUT_EXPECTATION.getRequestBodySpecification().isPresent()).isTrue(); assertThat(PUT_EXPECTATION.getRequestBodySpecification().get()).isInstanceOf(DefaultBodySpecification.class); } @Test public void shouldReturnSecuritySpecifications() { Map<String, SecurityScheme> schemes = GET_EXPECTATION.getSecuritySpecification(); assertThat(schemes.size()).isEqualTo(2); assertThat(schemes.containsKey("basic")).isTrue(); assertThat(schemes.containsKey("my-token")).isTrue(); }
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; public void shouldReturnRequestContentType() { assertThat(GET_EXPECTATION.getRequestContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnResponseContentType() { assertThat(GET_EXPECTATION.getResponseContentType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE); } @Test public void shouldReturnValidResponseBodySpecification() { assertThat(GET_EXPECTATION.getResponseBodySpecification().isPresent()).isTrue(); assertThat(GET_EXPECTATION.getResponseBodySpecification().get()).isInstanceOf(JsonBodySpecification.class); } @Test public void shouldReturnValidRequestBodySpecification() { assertThat(PUT_EXPECTATION.getRequestBodySpecification().isPresent()).isTrue(); assertThat(PUT_EXPECTATION.getRequestBodySpecification().get()).isInstanceOf(DefaultBodySpecification.class); } @Test public void shouldReturnSecuritySpecifications() { Map<String, SecurityScheme> schemes = GET_EXPECTATION.getSecuritySpecification(); assertThat(schemes.size()).isEqualTo(2); assertThat(schemes.containsKey("basic")).isTrue(); assertThat(schemes.containsKey("my-token")).isTrue(); }
@Test(expected = NoValidResourceException.class)
ozwolf-software/raml-mock-server
src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // }
import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response;
public void shouldReturnValidRequestBodySpecification() { assertThat(PUT_EXPECTATION.getRequestBodySpecification().isPresent()).isTrue(); assertThat(PUT_EXPECTATION.getRequestBodySpecification().get()).isInstanceOf(DefaultBodySpecification.class); } @Test public void shouldReturnSecuritySpecifications() { Map<String, SecurityScheme> schemes = GET_EXPECTATION.getSecuritySpecification(); assertThat(schemes.size()).isEqualTo(2); assertThat(schemes.containsKey("basic")).isTrue(); assertThat(schemes.containsKey("my-token")).isTrue(); } @Test(expected = NoValidResourceException.class) public void shouldThrowNoValidResourceExceptionWhenAttemptingToGetUriValueButNoMatchingResource() { ApiSpecification specification = mock(ApiSpecification.class); when(specification.getResourceFor(any(ApiExpectation.class))).thenReturn(Optional.empty()); new ApiExpectation(specification, MOCK_GET_EXPECTATION).getUriValueOf("name"); } @Test(expected = NoValidResourceException.class) public void shouldThrowNoValidResourceExceptionWhenAttemptingToGetSecuritySpecification() { ApiSpecification specification = mock(ApiSpecification.class); when(specification.getResourceFor(any(ApiExpectation.class))).thenReturn(Optional.empty()); new ApiExpectation(specification, MOCK_GET_EXPECTATION).getSecuritySpecification(); }
// Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidActionException.java // public class NoValidActionException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching action specification."; // // public NoValidActionException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/exception/NoValidResourceException.java // public class NoValidResourceException extends RamlMockServerException { // private final static String MESSAGE = "Expectation [ %s %s ] has no valid matching resource specification."; // // public NoValidResourceException(ApiExpectation expectation) { // super(String.format(MESSAGE, expectation.getMethod(), expectation.getUri())); // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/DefaultBodySpecification.java // public class DefaultBodySpecification implements BodySpecification { // private final MediaType mediaType; // // public DefaultBodySpecification(MediaType mediaType) { // this.mediaType = mediaType; // } // // @Override // public ValidationErrors validate(String body) { // return new ValidationErrors(); // } // // @Override // public MediaType getContentType() { // return mediaType; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java // public class JsonBodySpecification implements BodySpecification { // private final String bodyType; // private final MimeType mimeType; // // public JsonBodySpecification(String bodyType, MimeType mimeType) { // this.bodyType = bodyType; // this.mimeType = mimeType; // } // // @Override // public MediaType getContentType() { // return MediaType.APPLICATION_JSON_TYPE; // } // // @Override // public ValidationErrors validate(String body) { // if (mimeType.getSchema() == null) // return new ValidationErrors(); // // return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body); // } // } // Path: src/test/java/net/ozwolf/mockserver/raml/internal/domain/ApiExpectationTest.java import net.ozwolf.mockserver.raml.exception.NoValidActionException; import net.ozwolf.mockserver.raml.exception.NoValidResourceException; import net.ozwolf.mockserver.raml.internal.domain.body.DefaultBodySpecification; import net.ozwolf.mockserver.raml.internal.domain.body.JsonBodySpecification; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.mockserver.matchers.TimeToLive; import org.mockserver.mock.Expectation; import org.mockserver.model.Header; import org.mockserver.model.NottableString; import org.mockserver.model.Parameter; import org.raml.model.Resource; import org.raml.model.SecurityScheme; import org.raml.parser.visitor.RamlDocumentBuilder; import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import java.util.Map; import java.util.Optional; import static com.google.common.collect.Lists.newArrayList; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockserver.matchers.Times.once; import static org.mockserver.model.HttpRequest.request; import static org.mockserver.model.HttpResponse.response; public void shouldReturnValidRequestBodySpecification() { assertThat(PUT_EXPECTATION.getRequestBodySpecification().isPresent()).isTrue(); assertThat(PUT_EXPECTATION.getRequestBodySpecification().get()).isInstanceOf(DefaultBodySpecification.class); } @Test public void shouldReturnSecuritySpecifications() { Map<String, SecurityScheme> schemes = GET_EXPECTATION.getSecuritySpecification(); assertThat(schemes.size()).isEqualTo(2); assertThat(schemes.containsKey("basic")).isTrue(); assertThat(schemes.containsKey("my-token")).isTrue(); } @Test(expected = NoValidResourceException.class) public void shouldThrowNoValidResourceExceptionWhenAttemptingToGetUriValueButNoMatchingResource() { ApiSpecification specification = mock(ApiSpecification.class); when(specification.getResourceFor(any(ApiExpectation.class))).thenReturn(Optional.empty()); new ApiExpectation(specification, MOCK_GET_EXPECTATION).getUriValueOf("name"); } @Test(expected = NoValidResourceException.class) public void shouldThrowNoValidResourceExceptionWhenAttemptingToGetSecuritySpecification() { ApiSpecification specification = mock(ApiSpecification.class); when(specification.getResourceFor(any(ApiExpectation.class))).thenReturn(Optional.empty()); new ApiExpectation(specification, MOCK_GET_EXPECTATION).getSecuritySpecification(); }
@Test(expected = NoValidActionException.class)
ozwolf-software/raml-mock-server
src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java // public interface BodySpecification { // MediaType getContentType(); // // ValidationErrors validate(String body); // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java // public class ValidationErrors { // private final List<String> messages; // // public ValidationErrors() { // this.messages = newArrayList(); // } // // public void addMessage(String error, Object... formattedParameters) { // this.messages.add(String.format(error, formattedParameters)); // } // // public void combineWith(ValidationErrors errors) { // this.messages.addAll(errors.getMessages()); // } // // public boolean isInError() { // return !this.messages.isEmpty(); // } // // public List<String> getMessages() { // return messages; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/validator/body/content/JsonContentValidator.java // public class JsonContentValidator { // private final String bodyType; // // public JsonContentValidator(String bodyType) { // this.bodyType = bodyType; // } // // public ValidationErrors validate(String schema, String requestBody) { // ValidationErrors errors = new ValidationErrors(); // // try { // JsonNode schemaNode = JsonLoader.fromString(schema); // JsonNode dataNode = JsonLoader.fromString(requestBody); // // ProcessingReport report = JsonSchemaFactory.byDefault().getJsonSchema(schemaNode).validate(dataNode); // // if (!report.isSuccess()) // report.iterator().forEachRemaining(m -> errors.addMessage("[ %s ] [ body ] %s", bodyType, m.getMessage())); // } catch (Exception e) { // errors.addMessage("[ %s ] [ body ] Unexpected error of [ %s ] while validating JSON content", bodyType, e.getMessage()); // } // return errors; // } // }
import net.ozwolf.mockserver.raml.internal.domain.BodySpecification; import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors; import net.ozwolf.mockserver.raml.internal.validator.body.content.JsonContentValidator; import org.raml.model.MimeType; import javax.ws.rs.core.MediaType;
package net.ozwolf.mockserver.raml.internal.domain.body; public class JsonBodySpecification implements BodySpecification { private final String bodyType; private final MimeType mimeType; public JsonBodySpecification(String bodyType, MimeType mimeType) { this.bodyType = bodyType; this.mimeType = mimeType; } @Override public MediaType getContentType() { return MediaType.APPLICATION_JSON_TYPE; } @Override
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java // public interface BodySpecification { // MediaType getContentType(); // // ValidationErrors validate(String body); // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java // public class ValidationErrors { // private final List<String> messages; // // public ValidationErrors() { // this.messages = newArrayList(); // } // // public void addMessage(String error, Object... formattedParameters) { // this.messages.add(String.format(error, formattedParameters)); // } // // public void combineWith(ValidationErrors errors) { // this.messages.addAll(errors.getMessages()); // } // // public boolean isInError() { // return !this.messages.isEmpty(); // } // // public List<String> getMessages() { // return messages; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/validator/body/content/JsonContentValidator.java // public class JsonContentValidator { // private final String bodyType; // // public JsonContentValidator(String bodyType) { // this.bodyType = bodyType; // } // // public ValidationErrors validate(String schema, String requestBody) { // ValidationErrors errors = new ValidationErrors(); // // try { // JsonNode schemaNode = JsonLoader.fromString(schema); // JsonNode dataNode = JsonLoader.fromString(requestBody); // // ProcessingReport report = JsonSchemaFactory.byDefault().getJsonSchema(schemaNode).validate(dataNode); // // if (!report.isSuccess()) // report.iterator().forEachRemaining(m -> errors.addMessage("[ %s ] [ body ] %s", bodyType, m.getMessage())); // } catch (Exception e) { // errors.addMessage("[ %s ] [ body ] Unexpected error of [ %s ] while validating JSON content", bodyType, e.getMessage()); // } // return errors; // } // } // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java import net.ozwolf.mockserver.raml.internal.domain.BodySpecification; import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors; import net.ozwolf.mockserver.raml.internal.validator.body.content.JsonContentValidator; import org.raml.model.MimeType; import javax.ws.rs.core.MediaType; package net.ozwolf.mockserver.raml.internal.domain.body; public class JsonBodySpecification implements BodySpecification { private final String bodyType; private final MimeType mimeType; public JsonBodySpecification(String bodyType, MimeType mimeType) { this.bodyType = bodyType; this.mimeType = mimeType; } @Override public MediaType getContentType() { return MediaType.APPLICATION_JSON_TYPE; } @Override
public ValidationErrors validate(String body) {
ozwolf-software/raml-mock-server
src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java // public interface BodySpecification { // MediaType getContentType(); // // ValidationErrors validate(String body); // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java // public class ValidationErrors { // private final List<String> messages; // // public ValidationErrors() { // this.messages = newArrayList(); // } // // public void addMessage(String error, Object... formattedParameters) { // this.messages.add(String.format(error, formattedParameters)); // } // // public void combineWith(ValidationErrors errors) { // this.messages.addAll(errors.getMessages()); // } // // public boolean isInError() { // return !this.messages.isEmpty(); // } // // public List<String> getMessages() { // return messages; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/validator/body/content/JsonContentValidator.java // public class JsonContentValidator { // private final String bodyType; // // public JsonContentValidator(String bodyType) { // this.bodyType = bodyType; // } // // public ValidationErrors validate(String schema, String requestBody) { // ValidationErrors errors = new ValidationErrors(); // // try { // JsonNode schemaNode = JsonLoader.fromString(schema); // JsonNode dataNode = JsonLoader.fromString(requestBody); // // ProcessingReport report = JsonSchemaFactory.byDefault().getJsonSchema(schemaNode).validate(dataNode); // // if (!report.isSuccess()) // report.iterator().forEachRemaining(m -> errors.addMessage("[ %s ] [ body ] %s", bodyType, m.getMessage())); // } catch (Exception e) { // errors.addMessage("[ %s ] [ body ] Unexpected error of [ %s ] while validating JSON content", bodyType, e.getMessage()); // } // return errors; // } // }
import net.ozwolf.mockserver.raml.internal.domain.BodySpecification; import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors; import net.ozwolf.mockserver.raml.internal.validator.body.content.JsonContentValidator; import org.raml.model.MimeType; import javax.ws.rs.core.MediaType;
package net.ozwolf.mockserver.raml.internal.domain.body; public class JsonBodySpecification implements BodySpecification { private final String bodyType; private final MimeType mimeType; public JsonBodySpecification(String bodyType, MimeType mimeType) { this.bodyType = bodyType; this.mimeType = mimeType; } @Override public MediaType getContentType() { return MediaType.APPLICATION_JSON_TYPE; } @Override public ValidationErrors validate(String body) { if (mimeType.getSchema() == null) return new ValidationErrors();
// Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/BodySpecification.java // public interface BodySpecification { // MediaType getContentType(); // // ValidationErrors validate(String body); // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/ValidationErrors.java // public class ValidationErrors { // private final List<String> messages; // // public ValidationErrors() { // this.messages = newArrayList(); // } // // public void addMessage(String error, Object... formattedParameters) { // this.messages.add(String.format(error, formattedParameters)); // } // // public void combineWith(ValidationErrors errors) { // this.messages.addAll(errors.getMessages()); // } // // public boolean isInError() { // return !this.messages.isEmpty(); // } // // public List<String> getMessages() { // return messages; // } // } // // Path: src/main/java/net/ozwolf/mockserver/raml/internal/validator/body/content/JsonContentValidator.java // public class JsonContentValidator { // private final String bodyType; // // public JsonContentValidator(String bodyType) { // this.bodyType = bodyType; // } // // public ValidationErrors validate(String schema, String requestBody) { // ValidationErrors errors = new ValidationErrors(); // // try { // JsonNode schemaNode = JsonLoader.fromString(schema); // JsonNode dataNode = JsonLoader.fromString(requestBody); // // ProcessingReport report = JsonSchemaFactory.byDefault().getJsonSchema(schemaNode).validate(dataNode); // // if (!report.isSuccess()) // report.iterator().forEachRemaining(m -> errors.addMessage("[ %s ] [ body ] %s", bodyType, m.getMessage())); // } catch (Exception e) { // errors.addMessage("[ %s ] [ body ] Unexpected error of [ %s ] while validating JSON content", bodyType, e.getMessage()); // } // return errors; // } // } // Path: src/main/java/net/ozwolf/mockserver/raml/internal/domain/body/JsonBodySpecification.java import net.ozwolf.mockserver.raml.internal.domain.BodySpecification; import net.ozwolf.mockserver.raml.internal.domain.ValidationErrors; import net.ozwolf.mockserver.raml.internal.validator.body.content.JsonContentValidator; import org.raml.model.MimeType; import javax.ws.rs.core.MediaType; package net.ozwolf.mockserver.raml.internal.domain.body; public class JsonBodySpecification implements BodySpecification { private final String bodyType; private final MimeType mimeType; public JsonBodySpecification(String bodyType, MimeType mimeType) { this.bodyType = bodyType; this.mimeType = mimeType; } @Override public MediaType getContentType() { return MediaType.APPLICATION_JSON_TYPE; } @Override public ValidationErrors validate(String body) { if (mimeType.getSchema() == null) return new ValidationErrors();
return new JsonContentValidator(bodyType).validate(mimeType.getSchema(), body);