All Projects → Zeyad-37 → UseCases

Zeyad-37 / UseCases

Licence: Apache-2.0 license
This a library that offers a generic implementation of the data layers from the clean architecture by Uncle bob.

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to UseCases

Androidrapidlibrary
Android 快速开发库,主要想实现一条属于自己的开发框架。包括网络访问,数据,UI等等
Stars: ✭ 577 (+2408.7%)
Mutual labels:  rxjava, realm, retrofit2
Android tmdb clean architecture
Showcase of clean architecture concepts along with Continuous Integration and Development for modular Android applications. Includes test suits (functional and unit tests) along with code coverage.
Stars: ✭ 63 (+173.91%)
Mutual labels:  rxjava, clean-architecture, retrofit2
Clean Marvel Kotlin
This repository contains a detailed sample app that implements Clean architecture and MVP in Kotlin using RxJava2, Retrofit
Stars: ✭ 27 (+17.39%)
Mutual labels:  clean-architecture, realm, retrofit2
Newspaper
An aggregated newspaper app containing news from 10+ local news publishers in Hong Kong. Made with ❤
Stars: ✭ 82 (+256.52%)
Mutual labels:  rxjava, realm, retrofit2
Android Clean Architecture Mvvm Dagger Rx
Implemented by Clean Architecture, Dagger2, MVVM, LiveData, RX, Retrofit2, Room, Anko
Stars: ✭ 138 (+500%)
Mutual labels:  rxjava, clean-architecture, retrofit2
NewsReader
Android News Reader app. Kotlin Coroutines, Retrofit and Realm
Stars: ✭ 21 (-8.7%)
Mutual labels:  rxjava, realm, retrofit2
Star Wars Shop
Simple project with clean architecture and android lifecycle
Stars: ✭ 37 (+60.87%)
Mutual labels:  rxjava, clean-architecture, retrofit2
Kotlinrxmvparchitecture
Clean MVP Architecture with RxJava + Dagger2 + Retrofit2 + Mockito + Fresco + EasiestGenericRecyclerAdapter using Kotlin. Includes Unit Tests(Kotlin Tests)!
Stars: ✭ 94 (+308.7%)
Mutual labels:  rxjava, clean-architecture, retrofit2
Awesome Blogs Android
어썸블로그 ・ 개발 블로그 모음 ・ 개발 잡덕들을 위한 본격 고퀄리티 개발 블로그 큐레이션 서비스 🕵️‍♀️
Stars: ✭ 128 (+456.52%)
Mutual labels:  rxjava, realm, retrofit2
Doubanbook
一个基于 Clean 架构以及 Retrofit , RxKotlin , Dagger 框架实现的 Kotlin for Android App 。
Stars: ✭ 151 (+556.52%)
Mutual labels:  rxjava, clean-architecture, retrofit2
Movieguide Kotlin
Movie discovery app showcasing Kotlin, RxJava, Dagger2, MVP using Clean Architecture
Stars: ✭ 222 (+865.22%)
Mutual labels:  rxjava, clean-architecture, retrofit2
Roxie
Lightweight Android library for building reactive apps.
Stars: ✭ 441 (+1817.39%)
Mutual labels:  state-management, rxjava
Android-Starter-Kit
This is up-to-date android studio project for native android application, that is using modern tools and libraries.
Stars: ✭ 16 (-30.43%)
Mutual labels:  clean-architecture, retrofit2
Eva
Eva and Wall-e
Stars: ✭ 131 (+469.57%)
Mutual labels:  clean-architecture, retrofit2
Android-MVVM-News-App
MVVM News Application with clean code architecture & android jetpack components.
Stars: ✭ 38 (+65.22%)
Mutual labels:  clean-architecture, retrofit2
Grox
Grox helps to maintain the state of Java / Android apps.
Stars: ✭ 336 (+1360.87%)
Mutual labels:  state-management, rxjava
wikilight
A lightweight Wikipedia Client
Stars: ✭ 50 (+117.39%)
Mutual labels:  realm, retrofit2
ExamplesAndroid
Simple Example of Android [APIFacebook,APIGoogleMaps,APITwitter,Volley,Picasso etc etc etc]
Stars: ✭ 24 (+4.35%)
Mutual labels:  realm, retrofit2
Flutter Roadmap
This is a flutter roadmap and documentation repository. If anyone is interested you can join the party to help the community and make flutter great again.
Stars: ✭ 47 (+104.35%)
Mutual labels:  state-management, clean-architecture
photon
Fast and light image loading library based on kotlin
Stars: ✭ 20 (-13.04%)
Mutual labels:  rxjava, retrofit2

License

UseCases

Is a library that is a generic implementation of the Repository pattern applied in the Data layer in Uncle Bob's clean architecture. Now in Kotlin

Motivation

As developers, we always need to deliver high quality software on time, which is not an easy task. In most tasks, we need to make either a IO operation, whether from the server, db or file, which is a lot of boiler plate. And getting it functioning and efficient every time is a bit challenging due to the many things that you need to take care of. Like separation of concerns, error handling and writing robust code that would not crash on you. I have noticed that this code repeats almost with every user story, and i was basically re-writing the same code, but for different models. So i thought what if i could pass the class with the request and not repeat this code over and over. Hence, please welcome the UseCases lib.

Requirements

UseCases Library can be included in any Android application that supports Android 4.2 (Gingerbread) and later.

Installation

Easiest way to start

// Create Class Dao to expose your models to the lib configuration
// Standard Room init
@Dao
interface UserDao : BaseDao<User>

@Dao
interface RepoDao : BaseDao<Repository>

@Database(entities = [User::class, Repository::class], version = 1)
abstract class AppDatabase : RoomDatabase() {

    abstract fun userDao(): UserDao
    abstract fun repoDao(): RepoDao
}

// Fastest start
DataServiceFactory(DataServiceConfig.Builder(context).build()).instance!!// all extra features are disabled
                
// Advanced init
DataServiceFactory(DataServiceConfig.Builder(context)
            .baseUrl(API_BASE_URL)
            .okHttpBuilder(getOkHttpBuilder())
            .withRoom(object : DataBaseManagerUtil {
                                      override fun getDataBaseManager(dataClass: Class<*>): DataBaseManager? {
                                          return RoomManager(db, object : DaoResolver {
                                              override fun <E> getDao(dataClass: Class<E>): BaseDao<E> {
                                                  return when (dataClass) {
                                                      User::class.java -> db.userDao() as BaseDao<E>
                                                      Repository::class.java -> db.repoDao() as BaseDao<E>
                                                      else -> throw IllegalArgumentException("")
                                                  }
                                              }
                                          })
                                      }
                                  })
            .withCache(3, TimeUnit.MINUTES, 8192) // adds a cache layer with maximum size to allocate in bytes
            .okHttpBuilder(provideOkHttpClientBuilder()) 
            .okhttpCache(provideCache()) // you can also provide a cache for okHttp
            .postExecutionThread(AndroidScheduler.mainThread()) // your implementation of the post execution thread
            .build())
            .instance!!

Code Example

Get Object From Server:

dataService.<Order>getObject(GetRequest
        .GetRequestBuilder(Order::class.java, true) // true to save result to db, false otherwise.
        .url(URL) // if you provided a base url in the DataServiceConfig.Builder
        .idColumnName(Order.ID)
        .id(orderId)
        .build())
        .subscribe()

Get Object From DB:

mDataService.<Order>getObject(GetRequest
        .GetRequestBuilder(Order::class.java, true)
        .idColumnName(Order.ID)
        .id(mItemId)
        .build())
        .subscribe()

Get List From Server:

mDataService.<Order>getList(GetRequest
        .GetRequestBuilder(Order::class.java, false)
        .fullUrl(FULL_URL) // for server access
        .build())
        .subscribe()

Get List From DB:

mDataService.<Order>getList(GetRequest
        .GetRequestBuilder(Order::class.java, false)
        .build())
        .subscribe()

Post/Put Object:

mDataService.<MyResponse>postObject(PostRequest // putObject
        .PostRequestBuilder(Payload::class.java, true) // Type of expected server response
        .idColumnName(Order.ID) // for persistance
        .url(URL) // remove for DB access
        .payLoad(order) // or HashMap / JSONObject
        .responseType(MyResponse::class.java)
        .build())
        .subscribe()

Post/Put List:

mDataService.<MyResponse>postList(PostRequest // putList
        .PostRequestBuilder(Payload::class.java, true) // Type of expected server response
        .payLoad(orders)
        .idColumnName(Order.ID) // for persistance
        .url(URL) // remove for DB access
        .responseType(MyResponse::class.java)
        .build())
        .subscribe()

Delete Collection

mDataService().<MyResponse>deleteCollectionByIds(PostRequest // putList
        .PostRequestBuilder(Payload::class.java, true)
        .payLoad(ids)
        .idColumnName(Order.ID) // for persistance
        .url(URL) // remove for DB access
        .responseType(MyResponse::class.java)
        .build())
        .subscribe()

Delete Item:

mDataService().<MyResponse>deleteCollectionByIds(PostRequest // putList
        .PostRequestBuilder(Payload::class.java, true)
        .payLoad(id)
        .idColumnName(Order.ID) // for persistance
        .url(URL) // remove for DB access
        .responseType(MyResponse::class.java)
        .build())
        .subscribe()

Delete All from DB:

mDataService.deleteAll(PostRequest
        .PostRequestBuilder(Order::class.java, true)
        .idColumnName(Order.ID)
        .build())
        .subscribe()

Upload File

mDataService.<MyResponse>uploadFile(FileIORequest
        .FileIORequestBuilder(FULL_URL, File("")) // always full url
        .queuable(true, false) // onWifi, whileCharging
        .responseType(MyResponse::class.java)
        .build())
        .subscribe()

Download File

mDataService.downloadFile(FileIORequest
        .FileIORequestBuilder(FULL_URL, File(""))
        .queuable(true, false) // onWifi, whileCharging
        .requestType(Order::class.java)
        .build())
        .subscribe()

License

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].