Skip to content

Instantly share code, notes, and snippets.

ochi ochim

Block or report user

Report or block ochim

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ochim
ochim / ViewController.swift
Created Dec 5, 2019
[HealthKit]ヘルスケアデータにアクセスし、水泳のワークアウト、水泳のストローク数を取得し、出力する
View ViewController.swift
import UIKit
import HealthKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
guard HKHealthStore.isHealthDataAvailable() else {
return
}
@ochim
ochim / UIColor-hex.md
Created Nov 27, 2019
UIColorをカラーコードで生成する
View UIColor-hex.md
import UIKit

extension UIColor {
    convenience init(hex: String, alpha: CGFloat) {
        let v = Int("000000" + hex, radix: 16) ?? 0
        let r = CGFloat(v / Int(powf(256, 2)) % 256) / 255
@ochim
ochim / UITextField-attributedText-Tips.md
Created Nov 15, 2019
[ios]テキストを下寄せかつ、複数のフォントを混ぜて表示する
View UITextField-attributedText-Tips.md
//  下寄せ
valueField.contentVerticalAlignment = .bottom

let stringAttributes1: [NSAttributedString.Key: Any] = [
    .foregroundColor: UIColor.black,
    .font: UIFont.systemFont(ofSize: 30.0)
]
let string1 = NSAttributedString(string: v, attributes: stringAttributes1)
@ochim
ochim / looking-back-over-the-last-ten-years.md
Last active Sep 26, 2019
Looking back over the last 10 years
View looking-back-over-the-last-ten-years.md

2009

  • 価格比較、ランキングアプリ(iOS Obj-C)

2010

  • 囲碁アプリ(iOS Obj-C)
  • 生理日管理アプリ(iOS Obj-C)

2011

  • 生理日管理アプリ(iOS Obj-C)

2012

  • トレーディングカードアプリ(iOS Obj-C)

2013

View binary-gap.md
fun solution(N: Int): Int {
    // 2進数に変換
    val s = N.toString(2)
    // sが0を含まないなら0を返す
    if (!s.contains('0')) return 0

    var max = 0
    var count  = 0
@ochim
ochim / if-your-Android-app-is-currently-in-foreground.md
Last active Jun 25, 2019
Best way to know if your Android app is currently in foreground
View if-your-Android-app-is-currently-in-foreground.md

First

deprecated

public static boolean isApplicationInForeground(final Context context) {
    final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final List<RunningTaskInfo> tasks = activityManager.getRunningTasks(1);
    if (!tasks.isEmpty()) {
        final ComponentName topActivity = tasks.get(0).topActivity;
@ochim
ochim / android-getColor.md
Last active Jun 25, 2019
Android 6.0 Marshmallow (android sdk 23)からは getColorではなくContextCompat.getColor を使いましょう
View android-getColor.md
@ochim
ochim / check-if-specific-channel-enabled.md
Created Jun 19, 2019
Android 通知チャンネルを有効にしているかどうか判定する
View check-if-specific-channel-enabled.md
@ochim
ochim / AndroidNotification.md
Last active Jul 11, 2019
AndroidのNotificationを作成
View AndroidNotification.md

Android Oreoから通知を送るにはまずチャンネルを登録するようになった。
https://feel-log.net/android/developer/o-notification-no-sound-vibration/

int importance = NotificationManager.IMPORTANCE_;
NotificationChannel channel = new NotificationChannel(CHANNEL_ID, name, importance);
NotificationManager manager =
            (NotificationManager) getSystemService(Service.NOTIFICATION_SERVICE);
manager.createNotificationChannel(channel);
You can’t perform that action at this time.