Skip to content

Instantly share code, notes, and snippets.

View devrath's full-sized avatar
💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it

Devrath devrath

💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it
View GitHub Profile
export ANDROID_HOME=/Users/devrath/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
adb command not found
@devrath
devrath / sdkLocation
Created May 7, 2022 09:27
Sdk location in device
/Users/devrath/Library/Android/sdk
@devrath
devrath / CompositeDesignPatternOutput
Created April 24, 2022 10:42
Design pattern representing the output
Folder Details: Parent Folder
Folder Details: Software's
Folder Details: Movie's
File Details: Jurassic Park
Folder Details: Category drama movies
Folder Details: Game's
@devrath
devrath / CategoryDramaMoviesFolder.java
Created April 24, 2022 10:40
This snippet represents the composite design pattern
public class CategoryDramaMoviesFolder implements FolderDetailsComponent {
@Override
public void printFolderDetails() {
System.out.println("Folder Details: Category drama movies");
}
}
@devrath
devrath / BreakingNewsFragment.kt
Created March 15, 2022 12:18
Here we shall have a fragment that has a recycler view
class BreakingNewsFragment : Fragment(R.layout.fragment_breaking_news) {
private val viewModel: BreakingNewsViewModel by viewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val binding = FragmentBreakingNewsBinding.bind(view)
val newsArticleAdapter = NewsArticleListAdapter(
onItemClick = { article ->
@devrath
devrath / FileHelper.kt
Created February 20, 2022 07:19
File handling using the kotlin functions
class FileHelper {
companion object {
// From RAW folder
fun retrieveTextFromResources(context: Context, resourceId: Int): String {
return context.resources.openRawResource(resourceId).use { inputStream ->
// Here we get reference to input stream
inputStream.bufferedReader().use { bufferedReader ->
// Here we get reference to buffered reader
bufferedReader.readText()
}
@devrath
devrath / UsagesOfSealedClass.kt
Created January 30, 2022 10:36 — forked from rommansabbir/UsagesOfSealedClass.kt
How to use Kotlin's Sealed Class in Android Development for better & clean code
sealed class AppFailure {
/**
* Global Failure classes
* These failures will be used across all over the app including Data Layer, Domain Layer, Framework Layer
*/
class GeneralFailure(var message: String, var errorCode: Int? = null) : AppFailure()
class UnauthorizedFailure(var message: String = "Unauthorized", errorCode: Int? = null) : AppFailure()
class LoginFailure(var message: String = "Unable to login", errorCode: Int? = null) : AppFailure()
class ServerFailure(var message: String = "Unable to connect to the server side", errorCode: Int? = null) : AppFailure()
class NoInternetFailure(var message: String = "Device is not connected to the internet", errorCode: Int? = null) : AppFailure()
@devrath
devrath / ProgressTimer.kt
Last active November 19, 2021 14:47
Timer logic defined using the coroutines
class ProgressTimer(
private val player: Player,
private val positionListener: PositionListener,
@IoDispatcher private val ioDispatcher: CoroutineDispatcher
) {
companion object {
const val PROGRESS_TRACK_DURATION : Long = 1000
}
@devrath
devrath / ProgressJobTracker.kt
Created November 8, 2021 14:52
How to call the periodic callback of progress of Exo player
class ProgressJobTracker(
private val player: Player,
private val positionListener: PositionListener,
@IoDispatcher private val ioDispatcher: CoroutineDispatcher
) {
companion object {
const val PROGRESS_TRACK_DURATION : Long = 1000
}