-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Repository and UseCase for logout process
- Loading branch information
Showing
11 changed files
with
82 additions
and
36 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
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
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
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 |
---|---|---|
|
@@ -52,4 +52,4 @@ class ProgressDialogFragment : DaggerDialogFragment() { | |
} | ||
} | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
core/src/main/java/com/techchallenge/core/util/ext/Adapter.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.techchallenge.core.util.ext | ||
|
||
import androidx.recyclerview.widget.DiffUtil | ||
import com.techchallenge.core.util.delegate.AdapterItem | ||
import com.techchallenge.core.util.delegate.AdapterItemDiffUtil | ||
import com.techchallenge.core.util.delegate.ItemAdapter | ||
|
||
fun ItemAdapter.smartBind( | ||
items: MutableList<AdapterItem>, | ||
newItems: List<AdapterItem> | ||
) { | ||
if (items.isNullOrEmpty()) { | ||
items.clear() | ||
items.addAll(newItems) | ||
notifyDataSetChanged() | ||
} else { | ||
val diff = DiffUtil.calculateDiff(AdapterItemDiffUtil(items, newItems)) | ||
items.clear() | ||
items.addAll(newItems) | ||
diff.dispatchUpdatesTo(this) | ||
} | ||
} |
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
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
7 changes: 7 additions & 0 deletions
7
domain/src/main/java/com/techchallenge/domain/LogoutRepository.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.techchallenge.domain | ||
|
||
import io.reactivex.Completable | ||
|
||
interface LogoutRepository { | ||
fun logout(): Completable | ||
} |
17 changes: 17 additions & 0 deletions
17
domain/src/main/java/com/techchallenge/domain/LogoutRepositoryImpl.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.techchallenge.domain | ||
|
||
import com.techchallenge.core.local.BooleanPreference | ||
import com.techchallenge.core.local.LocalStorageModule.REMEMBER_ME_PREF | ||
import io.reactivex.Completable | ||
import javax.inject.Inject | ||
import javax.inject.Named | ||
|
||
class LogoutRepositoryImpl @Inject constructor( | ||
@Named(REMEMBER_ME_PREF) private val rememberMePref: BooleanPreference | ||
) : LogoutRepository { | ||
|
||
override fun logout(): Completable { | ||
rememberMePref.set(false) | ||
return Completable.complete() | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
domain/src/main/java/com/techchallenge/domain/LogoutUseCase.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.techchallenge.domain | ||
|
||
import com.techchallenge.core.UseCase | ||
import com.techchallenge.core.UseCase.None | ||
import io.reactivex.Completable | ||
import javax.inject.Inject | ||
|
||
class LogoutUseCase @Inject constructor( | ||
private val logoutRepository: LogoutRepository | ||
) : UseCase.CompletableUseCase<None> { | ||
|
||
override fun execute(params: None?): Completable { | ||
return logoutRepository.logout() | ||
} | ||
} |