Skip to content

Instantly share code, notes, and snippets.

@hardikm9850
Last active April 11, 2024 11:10
Show Gist options
  • Save hardikm9850/23ba37aad4d4260b495eed6917a25a6d to your computer and use it in GitHub Desktop.
Save hardikm9850/23ba37aad4d4260b495eed6917a25a6d to your computer and use it in GitHub Desktop.
Collecting my learnings under a single node

Articles explaining process related to layout inflation, event mechanism etc

The ViewGroup,View under Android Event Distribution Mechanism Source Code https://programmer.ink/think/the-viewgroup-view-under-android-event-distribution-mechanism-source-code.html

Deflating the LayoutInflater and working with findViewById() https://obvious.in/blog/deflating-the-layoutinflater-working-with-findviewbyid

Inside android application framework https://www.youtube.com/watch?v=TkPiXRNee7A

How Touch events are delivered https://suragch.medium.com/how-touch-events-are-delivered-in-android-eee3b607b038

Must know stuff of Android + OOPS

Inside the Android application framework

This session discusses about the Android application framework in depth, showing us the machinery behind the application framework. https://www.youtube.com/watch?v=TkPiXRNee7A

The best resource I came across Codepath Activity lifecycle during configuration change https://insomniacs.in/blog/understanding-activity-lifecycle-in-context-of-screen-rotation/

  1. Android basics Functional & Object-oriented programming Intents, services, activity, relationship between activity & framework and their life cycle Kotlin basics - Singleton, Data Class, Companion objects, Open/Sealed Class/Public, var & val, Null Safety, coroutines

  2. Basic UI Constructs in Android Types of views, Containers, Recycler view

  3. Architecture & Design patterns MVVM/MVP/MVC, Singleton/Façade/Observer

  4. Architecture application understanding Implementation with example

  5. Interoperability of Kotlin & Java Invoking Kotlin from Java and Vice Versa

  6. Advanced kotlin Skills Extension function, Lazy initialization, late init modifier, higher order function , inline function

  7. Device Specific Implementation Offline, Location, Maps, external device integrations Handling Bacground Tasks

  8. Reactive Programming RxJava/ RxAndroid vs Kotlin

  9. Understanding of REST APIs OKHttp, Retrofit & Handling models

  10. Unit Testing Exposure to Junit, Mockito, Kotlin test Networking & Security GIT, Jenkins/Gradle, Code Quality - Detekt, SonarQube, Android Signed Bundle/APK

  11. How does leak canary work? Read it here

  • Deep copy vs Shallow copy :: In a shallow copy, object B points to object A's location in memory. In deep copy, all things in object A's memory location get copied to object B's memory location.

  • Android bootup process Zygote, bootloader, kernel

  • Read about GC roots

There are 4 main types of GC root:

  1. Local variables, which belong to the stack of a thread.
  2. Instances of active Java threads.
  3. System Classes, which never unload.
  4. Native references, which are controlled by native code.

Something about architecture

SOLID Principle

Design pattern (4-5)

MVVM -> MVI 

architectural priciaple 

Activity lifecycle vs Fragment LC


Theory

How to write high code reusable, high code coverage

Viewmodel

What purpose does vm serve that MVP doesn't?

What is the difference between rx.Observable vs LiveData?

drawables PNG vs SVG, which is more efficient in terms of graphic?

OOPS concepts, inheritance, abstraction, how to prevent method overriding

Explain Build type, product flavor, build variant

Lifecycle owner?

Hashmap working

Map vs Hashmap

Databinding vs Viewbinding

SpannableString? Why string is immutable?

Viewstub, include, merge

dp,sp, why we don't use dp with textview?

OnDraw, OnMeausre, OnLayout significance of each method ReadMe And Me as well


Recyclerview


Jetpack components

Viewmodel

  • How to create VM instances with dependencies injected in constructors via Dagger multibinding here

  • How to restore app state after app's process death here


Screenshot 2021-11-22 at 8 12 23 PM

LayoutInflation

How does layout inflation work It has 3 steps from passing the layout resource id and getting a in memory view object More about it here

Security

How do you make your app secure? Visit me

Using BiometricPrompt with CryptoObject: how and why

Biometric Authentication on Android

  • How to take care of user password? Answer : Password verification commonly relies on cryptographic hashes. Storing all user passwords as cleartext can result in a massive security breach if the password file is compromised. One way to reduce this danger is to only store the hash digest of each password. To authenticate a user, the password presented by the user is hashed and compared with the stored hash. A password reset method is required when password hashing is performed; original passwords cannot be recalculated from the stored hash value. Stack exchange answer

How to store API keys and sensitive information? here hiding secrets in Android

  • Best practices for API design StackOVerFlow

  • How can you compress/shorten the data payload? -> Gzip

  • What is a CDN and How it can help optimise the data : image,video? -> Proxy server, provides optimised variant of images. Overall helps us achieve availability. This helps bring the resources closer to user implicitly reducing the latency

    More about it here

  • How can you make the serialisation of data more efficient? -> ProtoBuf

  • TCP handshake

  • Websocket

  • FCM working -> My understanding is that Android OS uses socket to handle FCM push notification i.e to continuosly receive data from server the connection has to stay open.

  • How to create a scalable webapp?

how-build-scalable-web-applications

scalability-design-principles-lars-larsso

Scalability Design Principles

Screenshot 2021-09-16 at 1 00 38 PM

Screenshot 2021-09-16 at 1 00 46 PM

Dagger

Dagger 1 vs Dagger 2

For instance, you can create a scope that only lasts the duration of an activity or fragment lifecycle. You can create a scope that maps only to a user authenticated session.

  • Usually the scope annotations are set for the Component and provide method.

  • If at least one provide method has a scope annotation the Component should have the same scope annotation.

  • The Component can be unscoped only if all provide methods in all its modules are unscoped too.

  • All scope annotations for one component (for all modules with provide methods to be a part of Component and for the Component itself) should be the same.

  • Two dependent components cannot share the same scope. For instance, two components cannot both be scoped as @Singleton

Important things to know:

  • A scoped provider creates one instance for that given scope for each component. Meaning a component keeps track of its own instances, but other components don't have a shared scope pool or some magic. To have one instance in a given scope, you need one instance of the component. This is why you must provide the ApplicationComponent to access its own scoped dependencies.

  • A component can subscope only one scoped component. Multiple scoped component dependencies are not allowed. more about it here

Components vs subcomponents

Difference Between Injection vs Inversion

  • Dependency Injection is an implementation technique for populating instance variables of a class.
  • Dependency Inversion is a general design guideline which recommends that classes should only have direct relationships with high-level abstractions.
  • Dependency Injection == “Gimme it” and Dependency Inversion == “Someone take care of this for me, somehow.”

more about it

https://stackoverflow.com/questions/29587130/dagger-2-subcomponents-vs-component-dependencies

How to improve the build time

Monolith vs Modularisation

How to optimise the app

How to modularise the app

  • By Joe The aim of this article was to provide a brief overview of the different modules that are available for android projects, as well as plant some seeds as to how you could approach modularization within your app.

Avoid screen jagging

One should take care about frame dropes, frozen frames. 16 ms/ frame is the ideal time for frame drawing. https://developer.android.com/topic/performance/vitals/frozen

Java

JVM vs JDK vs JRE

JDK is platform dependent, JRE is also platform dependent, but JVM is platform independent.

JDK contains tools for developing, debugging, etc. JRE contains class libraries and other supporting files, whereas software development tools are not included in JVM.

JDK comes with the installer, on the other hand, JRE only contains the environment to execute souurce code whereas JVM bundled in both software JDK and JRE.


Something about Thread and JVM

  • Thread internals and related design pattern The session will discuss the internals of Java threads and how some design patterns are implemented using them. This includes ordering of requests, resource management and avoiding head of line blocking

Does each thread has its own stack? More on it here

here

and here

Java Memory model (Stack Memory and Heap Space in Java)

Stack Memory
  • Stack Memory in Java is used for static memory allocation and the execution of a thread. It contains primitive values that are specific to a method and references to objects that are in a heap, referred from the method.

  • Access to this memory is in Last-In-First-Out (LIFO) order. Whenever a new method is called, a new block on top of the stack is created which contains values specific to that method, like primitive variables and references to objects.

  • When the method finishes execution, it’s corresponding stack frame is flushed, the flow goes back to the calling method and space becomes available for the next method.

  • This memory is threadsafe as each thread operates in its own stack

Heap Space in Java
  • Heap space in Java is used for dynamic memory allocation for Java objects and JRE classes at the runtime. New objects are always created in heap space and the references to this objects are stored in stack memory.

  • These objects have global access and can be accessed from anywhere in the application.

where does the classes and objects we create get stored in Java?
  • There is new keyword in Java used very often to create a new object. But what new does is allocate memory for the object of class you are making and returns a reference. That means, whenever you create an object as static or local, it gets stored in heap.

  • All the class variable primitive or object references (which is just a pointer to location where object is stored i.e. heap) are also stored in heap.

  • Classes loaded by ClassLoader and static variables and static object references are stored in a special location in heap which permanent generation.

  • Local primitive variables, local object references and method parameters are stored in stack.

  • Local Functions (methods) are stored in stack but static functions (methods) goes in permanent storage.

  • All the information related to a class like name of the class, object arrays associated with the class, internal objects used by JVM (like Java/Lang/Object) and optimization information goes into the Permanent Generation area.

So if the String would have been mutable, it's value could be changes from different threads, since String is stored in String pool (Heap area) which all the thread can access. That's why Strings are immutable :)

Reference 1 Reference 2

Java stack vs heap memory allocation explained

Screenshot 2021-03-17 at 9 08 54 AM

Screenshot 2021-03-17 at 9 08 46 AM

Garbage collection working

The Garbage-Collected Heap of the Java Virtual Machine

Concurrent programming

Complete JVM internal that one needs to know

Advance knowledge if Android threads and thread pools Here, we discuss about different Executors such as ThreadpoolExecutors,cachedPool,fixedPool,singlePool https://programmer.ink/think/advanced-knowledge-of-android-android-threads-and-thread-pools.html

Garbage collection in Android GC occurs in either of this scenaio

  1. When heap reaches to defined soft target
  2. When manually triggered
  3. When allocation fails

GC puts the object in 3 generation depending upon their use. It then uses mark and sweep algo to mark referenced objects and reclaims objects which are left unmarked Three generation : Young, Old, Permenant

  • The Young Generation contains the freshly allocated objects, allowing short living objects to be removed quickly. A garbage collection that happens here is called minor garbage collection.
  • The Old Generation contains older objects, the ones that are already alive for a longer time (Repositories, Application Class, etc.). Your view should actually have no business here. A garbage collection that happens here is called major garbage collection.
  • The Permanent Generation consists of meta data required for the runtime environment (JVM, ART, etc.) which is used to describe classes and methods.

https://medium.com/android-news/garbage-collection-explained-for-android-developers-and-any-other-jvm-language-ac5896bc8875 https://proandroiddev.com/collecting-the-garbage-a-brief-history-of-gc-over-android-versions-f7f5583e433c

Kotlin

Concurrency is the separation of tasks to provide interleaved execution. Parallelism is the simultaneous execution of multiple pieces of work in order to increase speed.

With threads, the operating system switches running threads preemptively according to its scheduler, which is an algorithm in the operating system kernel.

With coroutines, the programmer and programming language determine when to switch coroutines; in other words, tasks are cooperatively multitasked by pausing and resuming functions at set points, typically (but not necessarily) within a single thread.

In brief: In contrast to threads, which are pre-emptively scheduled by the operating system, coroutine switches are cooperative, meaning the programmer (and possibly the programming language and its runtime) controls when a switch will happen.

A language that supports native threads can execute its threads (user threads) onto the operating system's threads (kernel threads). Every process has at least one kernel thread. Kernel threads are like processes, except that they share memory space in their owning process with all other threads in that process. A process "owns" all its assigned resources, like memory, file handles, sockets, device handles, etc., and these resources are all shared among its kernel threads.

The operating system scheduler is part of the kernel that runs each thread for a certain amount time (on a single processor machine). The scheduler allocates time (timeslicing) to each thread, and if the thread isn't finished within that time, the scheduler pre-empts it (interrupts it and switches to another thread). Multiple threads can run in parallel on a multi-processor machine, as each thread can be (but doesn't necessarily have to be) scheduled onto a separate processor.

On a single processor machine, threads are timesliced and preempted (switched between) quickly (on Linux the default timeslice is 100ms) which makes them concurrent. However, they can't be run in parallel (simultaneously), since a single-core processor can only run one thing at a time.

Coroutines and/or generators can be used to implement cooperative functions. Instead of being run on kernel threads and scheduled by the operating system, they run in a single thread until they yield or finish, yielding to other functions as determined by the programmer. Languages with generators, such as Python and ECMAScript 6, can be used to build coroutines. Async/await (seen in C#, Python, ECMAscript 7, Rust) is an abstraction built on top of generator functions that yield futures/promises.

In some contexts, coroutines may refer to stackful functions while generators may refer to stackless functions.

Fibers, lightweight threads, and green threads are other names for coroutines or coroutine-like things. They may sometimes look (typically on purpose) more like operating system threads in the programming language, but they do not run in parallel like real threads and work instead like coroutines. (There may be more specific technical particularities or differences among these concepts depending on the language or implementation.)

For example, Java had "green threads"; these were threads that were scheduled by the Java virtual machine (JVM) instead of natively on the underlying operating system's kernel threads. These did not run in parallel or take advantage of multiple processors/cores--since that would require a native thread! Since they were not scheduled by the OS, they were more like coroutines than kernel threads. Green threads are what Java used until native threads were introduced into Java 1.2.

Threads consume resources. In the JVM, each thread has its own stack, typically 1MB in size. 64k is the least amount of stack space allowed per thread in the JVM. The thread stack size can be configured on the command line for the JVM. Despite the name, threads are not free, due to their use resources like each thread needing its own stack, thread-local storage (if any), and the cost of thread scheduling/context-switching/CPU cache invalidation. This is part of the reason why coroutines have become popular for performance critical, highly-concurrent applications.

Scrum methodology in depth

  • What is Scrum?

  • What is Backlog?

  • Role of Product owner and Scrum master?

  • Product backlog vs Story backlog?

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

TIL about blockchain
Blockchain for dummies

@hardikm9850
Copy link
Author

TIL about mocking/stubbing api
MockAPI

@hardikm9850
Copy link
Author

TIL about view toggle animation
Visibility toggle

@hardikm9850
Copy link
Author

hardikm9850 commented Jan 10, 2022

TIL about constraint layout Group. It helps in grouping views that we want to hide or show based upon certain situation
More
visibility-of-chain-group-in-constraint-layout

@hardikm9850
Copy link
Author

TIL how to provide different interface implementation of Dagger here

@hardikm9850
Copy link
Author

HILT Viewmodel explained

@hardikm9850
Copy link
Author

Improve Resume riggaro

@hardikm9850
Copy link
Author

TIL converting monolithic project into multi module project
Link

@hardikm9850
Copy link
Author

TIL how callback works between Android and JNI
Link

@hardikm9850
Copy link
Author

Books to read
here

@hardikm9850
Copy link
Author

hardikm9850 commented Apr 17, 2022

@hardikm9850
Copy link
Author

Teach yourself CS
https://teachyourselfcs.com/

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

TIL
How to create a python bot for scrapping tweets
https://realpython.com/twitter-bot-python-tweepy/

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

TIL How to remove recyclerview top and bottom shadow
android:overScrollMode="never"

@hardikm9850
Copy link
Author

TIL to configure multiple Git accounts on same machine
https://gist.github.com/Jonalogy/54091c98946cfe4f8cdab2bea79430f9

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

TIL Difference between Pro-guard vs R8
Pro-guard
SourceCode(.java) ---javac---> Java Bytecode(.class) ---Proguard---> Optimized Java bytecode(.class) ---Dex---> Dalvik Optimized Bytecode(.dex)

R8
SourceCode(.java) ---javac---> Java Bytecode(.class) ---R8---> Optimized Bytecode(.dex)

It has been reported that using R8 produces smaller .dex files, and does a more efficient minification of removing unused classes.

https://stackoverflow.com/questions/55744477/what-is-the-difference-between-proguard-and-r8

@hardikm9850
Copy link
Author

proguard-rules.pro is the file where you declare rules to related to proguard for you module & it's dependencies.

consumer-rules.pro is the file where you declare rules that can be applied on your module from consumer (whoever would be using your module/library as dependency, usually used by library devs.)

@hardikm9850
Copy link
Author

hardikm9850 commented Aug 8, 2022

GIT related questions.
git. git conflicts, git basics, and some advance stuff like git stash & rebase

git pro book
https://git-scm.com/book/en/v2

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

@hardikm9850
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment