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
import os | |
import re | |
for root, dirs, files in os.walk("."): | |
for file in files: | |
pkg = '' | |
if file == 'AndroidManifest.xml' and 'build' not in root: | |
print(os.path.join(root, file)) | |
content = open(os.path.join(root, file)).read() |
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
@CoDispatcher(DispatcherType.SHARED) | |
@Singleton | |
@Provides | |
fun sharedDispatcher(threadPoolExecutor: ThreadPoolExecutor): CoroutineDispatcher { | |
return threadPoolExecutor.asCoroutineDispatcher() | |
} |
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
@HiltViewModel | |
class HomeViewModel @Inject constructor( | |
private val redditRepository: RedditRepository, | |
@CoDispatcher(DispatcherType.SHARED) | |
private val coroutineDispatcher: CoroutineDispatcher | |
) : ViewModel() { | |
val reddits: LiveData<RedditListing> = redditRepository | |
.topReddits | |
.asLiveData(context = coroutineDispatcher) |
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
// DIModule.kt | |
@Provides | |
@Singleton | |
fun workManagerConfig(threadPoolExecutor: ThreadPoolExecutor): Configuration { | |
return Configuration.Builder() | |
.setExecutor(threadPoolExecutor) | |
.build() | |
} | |
// MainApplication.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
@Provides | |
@Singleton | |
fun okhttpClient( | |
threadPoolExecutor: ThreadPoolExecutor, | |
@ApplicationContext applicationContext: Context | |
): OkHttpClient { | |
val client = OkHttpClient.Builder() | |
.dispatcher(Dispatcher(threadPoolExecutor)) | |
.build() |
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
@Provides | |
@Singleton | |
fun threadPoolExecutor(): ThreadPoolExecutor { | |
val index = AtomicInteger() | |
return ThreadPoolExecutor( | |
Runtime.getRuntime().availableProcessors().coerceAtLeast(2), | |
Int.MAX_VALUE, | |
60, | |
TimeUnit.SECONDS, | |
SynchronousQueue(), |
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
ConnectivityThread | |
FinalizerDaemon | |
FinalizerWatchdogDaemon | |
HeapTaskDaemon | |
OkHttp TaskRunner | |
OkHttp TaskRunner | |
OkHttp TaskRunner | |
OkHttp www.reddit.com | |
Okio Watchdog | |
ReferenceQueueDaemon |
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
diff --git a/Flagship/build.gradle b/Flagship/build.gradle | |
index 9dd476b9e86..1ff6765ffb7 100644 | |
--- a/Flagship/build.gradle | |
+++ b/Flagship/build.gradle | |
@@ -131,7 +131,7 @@ android { | |
release { | |
minifyEnabled true | |
shrinkResources true | |
- proguardFiles getDefaultProguardFile('proguard-android.txt'), ('proguard-rules.pro') | |
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), ('proguard-rules.pro') |
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
class MainActivity : AppCompatActivity() { | |
private lateinit var binding: ActivityMainBinding | |
private lateinit var viewModel: MyViewModel | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
viewModel = ViewModelProvider(this).get(MyViewModel::class.java) | |
binding = ActivityMainBinding.inflate(layoutInflater) |
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
class MyViewModel : ViewModel() { | |
private val _sourceFlow = MutableStateFlow(0) | |
val sourceFlow: StateFlow<Int> | |
get() = _sourceFlow | |
private val _transformedFlow = _sourceFlow.map { | |
it * it | |
} | |
val transformedFlow: Flow<Int> |
NewerOlder