Skip to content

Instantly share code, notes, and snippets.

View Audhil's full-sized avatar
🎯
Focusing

Mohammed Audhil Audhil

🎯
Focusing
View GitHub Profile
@Audhil
Audhil / _1basics.ts
Last active October 28, 2022 16:31
Angular Basics
DOM(https://youtu.be/ipkjfvl40s0) - Document Object Model
object as a tree structure
DOM is an object-oriented representation of web page
Component(https://youtu.be/16rQyEQtpyQ?list=PLC3y8-rFHvwhBRAgFinJR8KHIrCdTkZcZ):
Template(view/HTML) + Class(code/typescript/data&methods) + Metadata(information decorator)
3 ways of declaring selector
1 -> selector: 'app-badwords' -> <app-badwords></app-badwords> in html file
// https://youtu.be/VWlwkqmTLHc?list=PLQkwcJG4YTCQcFEPuYGuv54nYai_lwil_
// USING TRY-CATCH FOR EXCEPTION HANDLING
// wrong
lifecycleScope.launch {
try {
launch {
throw Exception("failed")
}
} catch (e: Exception) {
}
@Audhil
Audhil / activity.kt
Last active September 15, 2022 14:01
Android basic brush up - AtoF & FtoA communication
class DummyActivity : AppCompatActivity(R.layout.activity_dummy) {
private val btn by lazy {
findViewById<Button>(R.id.btn)
}
private val tv by lazy {
findViewById<TextView>(R.id.tv)
}
var aToFragCallback: ActivityToFragCallBack<String>? = null
// exploring funcs & props usage in gradle file
// below code is placed in app/build.gradle
// executed tasks as `$ ./gradlew showMagics`
// https://medium.com/@dmitriileonov/5-gradle-things-that-get-android-developers-confused-ed606b8e8c92
class Foo {
def name = ""
void name(String newString) {
name = newString
println "Foo.name() triggered: name: $newString"
@Audhil
Audhil / CoroutineMistakes.kt
Created February 18, 2022 11:50
5 coroutine mistakes to avoid
package com.bhnetwork.scanit.consumer
import kotlinx.coroutines.*
import kotlin.random.Random
// mistake 1 - getFirstName call happens one after another
suspend fun getUserFirstNames(userIds: List<String>): List<String> {
val firstNames = mutableListOf<String>()
userIds.forEach {
firstNames.add(getFirstName(it))
@Audhil
Audhil / rounded_corner_ripple_btn.xml
Created August 9, 2021 14:25
adding ripple in rounded corner btns - usage: android:background="@drawable/rounded_corner_ripple_btn"
<?xml version="1.0" encoding="UTF-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:color="@color/black_10"
tools:targetApi="lollipop"><!-- ripple effect color -->
<!-- background color -->
<item android:id="@android:id/background">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent" />
@Audhil
Audhil / AnyFrag.kt
Created June 30, 2021 17:08
Dynamically changing(Overriding) - color from colors.xml
class DynamicHomeFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val color2 = requireActivity().application.resources.getColor(R.color.your_special_color, null) // returns Color.GREEN
binding.content.ll3.setBackgroundColor(color2)
}
}
@Audhil
Audhil / ContentView.swift
Created May 4, 2021 15:28
hands dirty on Swift-UI
//
// ContentView.swift
// SwiftUI-Appu
//
// Created by Mohammed Audhil S on 18/04/21.
//
import SwiftUI
struct ContentView: View {
@Audhil
Audhil / _1ActivityWithOverflowMenu.kt
Last active November 27, 2020 17:22
A simple activity demonstrating use of a NavHostFragment with a navigation drawer or overflow menu. for ref: https://codelabs.developers.google.com/codelabs/android-navigation/#8 explore for deeplinks with navigations and more src code @ https://drive.google.com/drive/folders/10El0eDzCEL1OnTKlFBXwZfq4XdtukGMA?usp=sharing
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.navigation_activity)
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
val host: NavHostFragment = supportFragmentManager
.findFragmentById(R.id.my_nav_host_fragment) as NavHostFragment? ?: return
@Audhil
Audhil / designSwiggyApp.txt
Created September 30, 2020 14:34
designing a Swiggy app!
Designing Swiggy-app!
requirements
Kotlin
MVVM - MVI etc
android arch components
Dagger-Hilt, MockK
retrofit2
kotlin coroutines