Skip to content

Instantly share code, notes, and snippets.

View Nike2406's full-sized avatar
🎯
Focusing

Nick Nike2406

🎯
Focusing
View GitHub Profile
@Nike2406
Nike2406 / gist:4cd10df7fb06a61d2cbdde0efb5d27f8
Created April 8, 2025 09:30
Exclude generated Hilt files
1. With your Android Studio open, click on the ‘File’ menu.
2. Then select ‘Settings’.
3. In the ‘Editor’ tab, navigate to ‘File Types’.
4. Within this menu, click on the ‘Ignored Files and Folders’ window.
5. Add this sources.
*DaggerComponent.java
*DaggetModule.java
*Hilt*.java
@Nike2406
Nike2406 / gist:3ef5bd726ee4d47447d13155a0b36eab
Created December 18, 2024 10:42
Preventing Font Scaling
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.sp
val TextUnit.nonScaledSp
@Composable
get() = (this.value / LocalDensity.current.fontScale).sp
// Example:
@Nike2406
Nike2406 / gist:b135dfee8445b4c695e3f54b64c8c8b0
Created December 17, 2024 14:51
Compose: Context.getActivity()
fun Context.getActivity(): ComponentActivity? = when (this) {
is ComponentActivity -> this
is ContextWrapper -> baseContext.getActivity()
else -> null
}