Skip to content

Instantly share code, notes, and snippets.

View numanayhan's full-sized avatar
🏈
Coding

Numan Ayhan numanayhan

🏈
Coding
  • Istanbul
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
@numanayhan
numanayhan / MultiLiveMain.java
Last active August 24, 2020 08:43
MultiLiveData
public class MultiLiveMain extends AppCompatActivity implements View.OnClickListener {
TextView show_products, pieceText;
AppCompatActivity activity;
ProductModal productModal;
Observer<Integer> productObserver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@numanayhan
numanayhan / ProductModal.java
Created August 24, 2020 08:43
ProductModal
public class ProductModal extends ViewModel {
private MutableLiveData<Integer> count;
public MutableLiveData<Integer> getCount() {
if (count == null) {
count = new MutableLiveData<>();
}
return count;
}
}
@numanayhan
numanayhan / iterm2-solarized.md
Created November 29, 2021 10:50 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

func validate(response: HTTPResponse, forRequest request: HTTPRequest) -> HTTPResponseValidatorResult {
if !(200..<300).contains(response.statusCode) {
// invalid response, we want to fail the request with error
throw HTTPError.invalidResponse
}
return .nextValidator // everything is okay, move to next validator
}
@numanayhan
numanayhan / CoreTelephonyCheck.swift
Created October 29, 2022 15:13 — forked from krin-san/CoreTelephonyCheck.swift
Check if iOS device is capable to call / send SMS message
// Swift version of the code from http://stackoverflow.com/a/30335594/1986600
import CoreTelephony
override func awakeFromNib() {
super.awakeFromNib()
let isCapableToCall: Bool
if UIApplication.sharedApplication().canOpenURL(NSURL(string: "tel://")!) {
// Check if iOS Device supports phone calls
@numanayhan
numanayhan / UILabelSize.swift
Created June 11, 2023 09:22 — forked from fuxingloh/UILabelSize.swift
iOS Swift: How to find text width, text height or size of UILabel.
extension UILabel {
func textWidth() -> CGFloat {
return UILabel.textWidth(label: self)
}
class func textWidth(label: UILabel) -> CGFloat {
return textWidth(label: label, text: label.text!)
}
class func textWidth(label: UILabel, text: String) -> CGFloat {