-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/JP-Cache' into develop
- Loading branch information
Showing
58 changed files
with
251 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,71 @@ | ||
# JPMorganTest | ||
Test | ||
## CESAR CANAZA | ||
|
||
Mobile developer willing to learn old and new technologies, I like the team work and communication. | ||
Thank you for check this project. | ||
|
||
## Architecture MVVM with clean | ||
|
||
### data (Repositories - Framework) | ||
- di: Contains the dependency injection with hilt | ||
- settings: Contains all the settings local `(Convertes, SharedEncription)` and network `(Interceptor, Cookie, more)` | ||
- sources: Contains all the content of each feature `For example: Search` like `framework database or retrofit` the connection is through repository | ||
- di: Contains the dependency injection of the Feature like `Search` | ||
- entities: Contains all the entities of the feature like `Search` | ||
- mapper: Contains all the mapper of the feature | ||
- local: Contains the framework with the local storage | ||
- remote: Contains the framework to connect the data using `voley, retrofit or other` | ||
- repository files: Contains the interface and the implementation of the connections with the local and remote data | ||
### domain (Model - Use Case) | ||
- usecase: | ||
- entities: Contains all the entities in domain with the logic if they have | ||
- usecase Files: Contains each use case of the app where we can sort, filter and others | ||
### presentation (ViewModel - Screen UI) | ||
- Main Activity: Contains the main activity in jetpack compose | ||
- Screen Directory: Contains all the resources that manage a screen like **View Model, CustomComposable, State, Screen** | ||
- delegate: Contains Singleton classes that work when we need to share contents between ViewModel where we **delegate the action to do something** or **save something light** | ||
### Additional comments | ||
- ui: Package that contains all the layers like **Permission, General Composables, NavigationComponent, Theme, Services** | ||
- util: Contains global Constants and Extension Functions | ||
## FILE WITH JAVA | ||
- domain/base/SuspendNoParamsUseCase.java | ||
- data/sources/search/mapper/SearchResultMapperImpl.java | ||
- data/sources/search/local/SearchLocalDataSourceImpl.java | ||
## Technology Stack | ||
- Kotlin Programming language | ||
- Java: Programming language | ||
- MVVM: Architecture design that help us to decouple our code in layers | ||
- Retrofit: Library that help us to consume ApiRest | ||
- JUnit: Framework that help us to test code | ||
- Kotlin Coroutines: Provides ways to manage threads very easily | ||
- Flow: Library that help us to manage the asynchronous stream data | ||
- Mockk: Library for Mock data in the unit test | ||
- Jetpack Compose: Framework for UI using Kotlin where we developed the code like puzzles | ||
- Hilt: Dependency Injection in Compile-Time | ||
- Jetpack Navigation: library that simplify and streamline the navigation between composables or screens | ||
- Jacoco: Generate Files of the coverage of the unit test | ||
- KLint: Format the code for give my quality to the project | ||
- Detekt: Code analysis tool that help us to follow rules in the code | ||
- others like: Google accompanist, Turbine .... | ||
## Configuration: | ||
### Local.properties | ||
Add this line | ||
``` | ||
WEATHER_KEY=751d80f6c314139192ffcb62c107e654 | ||
SHARED_PREFERENCES_NAME=dbappjpmorgan | ||
BASE_URL=https://api.openweathermap.org/ | ||
``` | ||
### Gradle Java | ||
|
||
Go to **Gradle JDK** and change to **Java17** | ||
|
||
![Java](image/gradle_j17.png) | ||
|
||
### DOWNLOAD APP | ||
## Download the app by Google Drive | ||
- [GOOGLE DRIVE](https://drive.google.com/drive/folders/1DV46UTecrTV2EdjYL2M6HMVA0CiD7H0K?usp=sharing) | ||
## Download the app by artifact github | ||
Go to [Here](https://github.com/cesarwillymc/JPMorganTest/actions) | ||
- ![APK](image/artifact.png) | ||
Later select the first workflow and download the apk | ||
- ![APK](image/app.png) |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/src/main/java/com/cesarwillymc/jpmorgantest/data/di/NetworkModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ocal/EncryptedSharedPreferencesFactory.kt → ...ocal/EncryptedSharedPreferencesFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ata/sources/network/WeatherInterceptor.kt → ...ta/settings/network/WeatherInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
...rces/network/util/BaseRemoteDataSource.kt → ...ings/network/util/BaseRemoteDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ata/sources/network/util/DefaultClient.kt → ...ta/settings/network/util/DefaultClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ta/sources/network/util/error/ErrorApi.kt → ...a/settings/network/util/error/ErrorApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ources/network/util/error/ErrorHandler.kt → ...ttings/network/util/error/ErrorHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sources/network/util/error/ErrorSource.kt → ...ettings/network/util/error/ErrorSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...va/com/cesarwillymc/jpmorgantest/data/sources/search/local/SearchLocalDataSourceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.cesarwillymc.jpmorgantest.data.sources.search.local; | ||
|
||
import android.content.SharedPreferences; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.cesarwillymc.jpmorgantest.util.constants.ConstantsKt; | ||
import com.cesarwillymc.jpmorgantest.util.state.Result; | ||
|
||
import javax.inject.Inject; | ||
|
||
import kotlin.Unit; | ||
import kotlin.jvm.JvmField; | ||
|
||
|
||
/** | ||
* Created by Cesar Canaza on 10/4/23. | ||
* cesarwilly.mc@gmail.com | ||
* <p> | ||
* IOWA, United States. | ||
*/ | ||
public class SearchLocalDataSourceImpl implements SearchLocalDataSource { | ||
private final SharedPreferences sharedPreferences; | ||
|
||
@Inject | ||
public SearchLocalDataSourceImpl(SharedPreferences sharedPreferences) { | ||
this.sharedPreferences = sharedPreferences; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Result<Unit> saveQuery(@NonNull String value) { | ||
try { | ||
SharedPreferences.Editor editor = sharedPreferences.edit(); | ||
if (value.isEmpty()) { | ||
editor.remove(RECENTLY_SEARCHED); | ||
} else { | ||
editor.putString(RECENTLY_SEARCHED, value); | ||
} | ||
editor.apply(); | ||
return new Result.Success<>(null); | ||
} catch (Exception e) { | ||
return new Result.Error(e); | ||
} | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Result<String> recentlySearched() { | ||
try { | ||
String result = sharedPreferences.getString( | ||
RECENTLY_SEARCHED, | ||
ConstantsKt.EMPTY_STRING | ||
); | ||
if (result.isBlank()) { | ||
return new Result.Error(new Exception()); | ||
} else { | ||
return new Result.Success<>(result); | ||
} | ||
} catch (Exception e) { | ||
return new Result.Error(e); | ||
} | ||
} | ||
|
||
@JvmField | ||
static String RECENTLY_SEARCHED = "recently_searched"; | ||
} |
53 changes: 0 additions & 53 deletions
53
...java/com/cesarwillymc/jpmorgantest/data/sources/search/local/SearchLocalDataSourceImpl.kt
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
...java/com/cesarwillymc/jpmorgantest/data/sources/search/mapper/SearchResultMapperImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.cesarwillymc.jpmorgantest.data.sources.search.mapper; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.cesarwillymc.jpmorgantest.data.sources.search.entities.WeatherDetailResponse; | ||
import com.cesarwillymc.jpmorgantest.domain.usecase.entities.WeatherDetail; | ||
import com.cesarwillymc.jpmorgantest.util.constants.ConstantsKt; | ||
|
||
import javax.inject.Inject; | ||
|
||
/** | ||
* Created by Cesar Canaza on 10/4/23. | ||
* cesarwilly.mc@gmail.com | ||
* <p> | ||
* IOWA, United States. | ||
*/ | ||
public class SearchResultMapperImpl implements SearchResultMapper { | ||
@Inject | ||
public SearchResultMapperImpl(){} | ||
|
||
@NonNull | ||
@Override | ||
public WeatherDetail fromResponseToDomain(@NonNull WeatherDetailResponse info) { | ||
return new WeatherDetail( | ||
info.getName(), | ||
info.getMain().getFeelsLike(), | ||
info.getWeather().isEmpty() ? ConstantsKt.EMPTY_STRING : info.getWeather().get(ConstantsKt.ZERO).getDescription(), | ||
info.getMain().getHumidity(), | ||
info.getMain().getPressure(), | ||
info.getWind().getSpeed(), | ||
info.getSys().getSunrise(), | ||
info.getSys().getSunset(), | ||
info.getWeather().isEmpty() ? ConstantsKt.EMPTY_STRING : info.getWeather().get(ConstantsKt.ZERO).getIcon() | ||
); | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
...n/java/com/cesarwillymc/jpmorgantest/data/sources/search/mapper/SearchResultMapperImpl.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...va/com/cesarwillymc/jpmorgantest/data/sources/search/remote/SearchRemoteDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/src/main/java/com/cesarwillymc/jpmorgantest/domain/base/SuspendNoParamsUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.cesarwillymc.jpmorgantest.domain.base; | ||
|
||
import static com.cesarwillymc.jpmorgantest.util.constants.ConstantsKt.LOG_DOMAIN; | ||
import android.util.Log; | ||
import com.cesarwillymc.jpmorgantest.util.state.Result; | ||
|
||
/** | ||
* Created by Cesar Canaza on 10/3/23. | ||
* cesarwilly.mc@gmail.com | ||
* <p> | ||
* IOWA, United States. | ||
* <p> | ||
* It can be used for use cases that return Unit, Boolean, Int, etc. | ||
* No mapper needed | ||
*/ | ||
public abstract class SuspendNoParamsUseCase<Results> { | ||
|
||
public Result<Results> invoke() { | ||
try { | ||
return execute(); | ||
} catch (Exception e) { | ||
Log.e(LOG_DOMAIN, e.getMessage()); | ||
return new Result.Error.Error(e); | ||
} | ||
} | ||
|
||
protected abstract Result<Results> execute() throws Exception; | ||
} |
Oops, something went wrong.