Skip to content

Instantly share code, notes, and snippets.

View kerimovscreations's full-sized avatar
🗺️
Solves problems using codes. Genetic codes.

Karim Karimov kerimovscreations

🗺️
Solves problems using codes. Genetic codes.
View GitHub Profile
@kerimovscreations
kerimovscreations / clean_migration_guides.md
Created February 23, 2022 05:45
Migrate legacy project to Clean architecture

Migration steps

~ marked steps will be replaced with dependency injection in the following steps.

1. Define View models

Start to move all business logic from view controller into view models.

~ Initialize view models in the view controllers.

fun getShortenedCount(count: Int): String {
return if (count < 1000) {
count.toString()
} else if (count < 1000000) {
val firstPart = count / 1000
val secondPart = count % 1000 / 100
if (secondPart > 0) {
"$firstPart,${secondPart}k}"
} else {
"${firstPart}k"
@kerimovscreations
kerimovscreations / click-outside.directive.ts
Last active August 21, 2019 12:20
Click outside directive testing example
import { Directive, ElementRef, Output, HostListener, EventEmitter } from '@angular/core';
@Directive({
selector: '[appClickOutside]'
})
export class ClickOutsideDirective {
constructor(private elementRef: ElementRef) { }
@Output()
public static String getRelativeTimeSpanString(Context context, Date fromdate) {
long then;
then = fromdate.getTime();
Date date = new Date(then);
StringBuilder dateStr = new StringBuilder();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.FrameLayout;
/**
* Layout that provides pinch-zooming of content. This view should have exactly one child
* view containing the content.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--https://raw.githubusercontent.com/wada811/Android-Material-Design-Colors/master/library/src/main/res/values/colors.xml-->
<!-- red -->
<color name="md_red_50">#ffebee</color>
<color name="md_red_100">#ffcdd2</color>
<color name="md_red_200">#ef9a9a</color>
<color name="md_red_300">#e57373</color>