Skip to content

Instantly share code, notes, and snippets.

View OmarKRostom's full-sized avatar
👨‍💻
Shush ... crafting some software

Omar Khairy Rostom OmarKRostom

👨‍💻
Shush ... crafting some software
View GitHub Profile
@OmarKRostom
OmarKRostom / ArcLayoutManager.kt
Created March 7, 2021 15:35
Final version of the ArcLayoutManager
package com.omarkrostom.arclayoutmanager
import android.content.Context
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import androidx.recyclerview.widget.RecyclerView
import kotlin.math.*
class ArcLayoutManager(
private val context: Context,
@OmarKRostom
OmarKRostom / ArcLayoutManager.kt
Last active March 17, 2021 04:17
Third step creating an arc layout manager
private fun fill(recycler: RecyclerView.Recycler?, state: RecyclerView.State?) {
detachAndScrapAttachedViews(recycler ?: return)
for (itemIndex in 0 until itemCount) {
val view = recycler.getViewForPosition(itemIndex)
addView(view)
val viewWidth = pxFromDp(context, ITEM_WIDTH)
val viewHeight = pxFromDp(context, ITEM_HEIGHT)
@OmarKRostom
OmarKRostom / ArcLayoutManager.kt
Last active March 17, 2021 04:20
Second step creating an arc layout manager
class ArcLayoutManager(
private val context: Context,
private var horizontalOffset: Int = 0
) : RecyclerView.LayoutManager() {
override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams =
RecyclerView.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
override fun canScrollHorizontally(): Boolean = true
override fun scrollHorizontallyBy(
@OmarKRostom
OmarKRostom / ArcLayoutManager.kt
Created March 7, 2021 13:45
First step creating an arc layout manager
package com.omarkrostom.arclayoutmanager
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
class ArcLayoutManager: RecyclerView.LayoutManager() {
override fun generateDefaultLayoutParams(): RecyclerView.LayoutParams =
RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
}
@OmarKRostom
OmarKRostom / computeY.kt
Created March 7, 2021 13:40
ComputeY component for a circular recyclerview
private fun computeYComponent(viewCenterX: Float,
h: Float): Pair<Int, Double> {
val screenWidth = context.resources.displayMetrics.widthPixels
val s = screenWidth.toDouble() / 2
val radius = (h * h + s * s) / (h * 2)
val xScreenFraction = viewCenterX.toDouble() / screenWidth.toDouble()
val beta = acos(s / radius)
val alpha = beta + (xScreenFraction * (Math.PI - (2 * beta)))
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
@OmarKRostom
OmarKRostom / HorizontalCarouselRecyclerView.kt
Created October 19, 2020 05:59
A recyclerview to apply the scaling effect on scrolling
import android.animation.ArgbEvaluator
import android.content.Context
import android.graphics.ColorMatrix
import android.graphics.ColorMatrixColorFilter
import android.util.AttributeSet
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.TextView
@OmarKRostom
OmarKRostom / ArcLayoutManager.kt
Last active March 17, 2021 04:21
This is a layout manager to draw items on a cruve like design
package com.omarkrostom.arclayoutmanager
import android.content.Context
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import androidx.recyclerview.widget.RecyclerView
import kotlin.math.*
class ArcLayoutManager(
private val context: Context,
@OmarKRostom
OmarKRostom / Android-Fastlane-Awesome.fastfile
Created June 29, 2020 08:49
Your quick and reliable Fastlane configuration for Android
# Here is {MY_APP_BETA} configuration file
default_platform(:android)
platform :android do
desc "Submit a new {MY_APP_BETA} Build to Crashlytics"
lane :{MY_APP_BETA} do
gradle(task: "clean assemble{MY_APP_BETA}")
firebase_app_distribution(
app: "{REPLACE_WITH_FIREBASE_API_KEY_FOR_YOUR_PROJET}"
)
@OmarKRostom
OmarKRostom / Android-CircleCI-Awesome.yml
Last active June 29, 2020 13:58
Your quick and reliable CircleCI configuration for Android
version: 2.1
references:
#Android Configuration Block
android_config: &android_config
working_directory: ~/{MY-APP}
docker:
- image: circleci/android:api-29
environment:
_JAVA_OPTIONS: -Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
GRADLE_OPTS: -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false