From e3403cd172eb5cf0864e97b786efcdc14dc1c4a4 Mon Sep 17 00:00:00 2001 From: Mohsen Mirhoseini Argi Date: Tue, 10 Jan 2017 10:48:51 +0330 Subject: [PATCH] Fix Console module --- .../com/mirhoseini/marvel/ConsoleModule.java | 25 +++++++++++--- .../marvel/util/ConsoleConstants.java | 10 ++++++ .../marvel/util/StateManagerImpl.java | 34 +++++++++++++++++++ 3 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 console/src/main/java/com/mirhoseini/marvel/util/ConsoleConstants.java create mode 100644 console/src/main/java/com/mirhoseini/marvel/util/StateManagerImpl.java diff --git a/console/src/main/java/com/mirhoseini/marvel/ConsoleModule.java b/console/src/main/java/com/mirhoseini/marvel/ConsoleModule.java index d928823..802a0cb 100644 --- a/console/src/main/java/com/mirhoseini/marvel/ConsoleModule.java +++ b/console/src/main/java/com/mirhoseini/marvel/ConsoleModule.java @@ -1,8 +1,11 @@ package com.mirhoseini.marvel; +import com.mirhoseini.marvel.util.ConsoleConstants; import com.mirhoseini.marvel.util.ConsoleSchedulerProvider; import com.mirhoseini.marvel.util.Constants; import com.mirhoseini.marvel.util.SchedulerProvider; +import com.mirhoseini.marvel.util.StateManager; +import com.mirhoseini.marvel.util.StateManagerImpl; import java.io.File; @@ -31,13 +34,13 @@ boolean provideIsDebug() { @Singleton @Named("networkTimeoutInSeconds") int provideNetworkTimeoutInSeconds() { - return Constants.NETWORK_CONNECTION_TIMEOUT; + return ConsoleConstants.NETWORK_CONNECTION_TIMEOUT; } @Provides @Singleton HttpUrl provideEndpoint() { - return HttpUrl.parse(Constants.BASE_URL); + return HttpUrl.parse(ConsoleConstants.BASE_URL); } @Provides @@ -50,21 +53,28 @@ SchedulerProvider provideAppScheduler() { @Singleton @Named("cacheSize") long provideCacheSize() { - return Constants.CACHE_SIZE; + return ConsoleConstants.CACHE_SIZE; } @Provides @Singleton @Named("cacheMaxAge") int provideCacheMaxAgeMinutes() { - return Constants.CACHE_MAX_AGE; + return ConsoleConstants.CACHE_MAX_AGE; } @Provides @Singleton @Named("cacheMaxStale") int provideCacheMaxStaleDays() { - return Constants.CACHE_MAX_STALE; + return ConsoleConstants.CACHE_MAX_STALE; + } + + @Provides + @Singleton + @Named("retryCount") + public int provideApiRetryCount() { + return ConsoleConstants.API_RETRY_COUNT; } @Provides @@ -80,4 +90,9 @@ boolean provideIsConnect() { return true; } + @Provides + @Singleton + public StateManager provideStateManager(StateManagerImpl stateManager) { + return stateManager; + } } diff --git a/console/src/main/java/com/mirhoseini/marvel/util/ConsoleConstants.java b/console/src/main/java/com/mirhoseini/marvel/util/ConsoleConstants.java new file mode 100644 index 0000000..4b7a460 --- /dev/null +++ b/console/src/main/java/com/mirhoseini/marvel/util/ConsoleConstants.java @@ -0,0 +1,10 @@ +package com.mirhoseini.marvel.util; + +/** + * Created by Mohsen on 10/01/2017. + */ +public class ConsoleConstants extends Constants { + + public static final int API_RETRY_COUNT = 3; + +} diff --git a/console/src/main/java/com/mirhoseini/marvel/util/StateManagerImpl.java b/console/src/main/java/com/mirhoseini/marvel/util/StateManagerImpl.java new file mode 100644 index 0000000..9d0fddd --- /dev/null +++ b/console/src/main/java/com/mirhoseini/marvel/util/StateManagerImpl.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 Karina Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and limitations under the License. + */ + +package com.mirhoseini.marvel.util; + +import javax.inject.Inject; + +/** + * Created by Mohsen on 06/11/2016. + */ + +public class StateManagerImpl implements StateManager { + + + @Inject + public StateManagerImpl() { + + } + + @Override + public boolean isConnect() { + return true; + } +}