alt + enter 자동완성

ctrl + space 자동완성 basic code completion

현재 year 가져오기 Calendar.getInstance().get(Calendar.YEAR)

UI를 위한 변수를 자동생성 해주기 위해 필요    

import kotlinx.android.sythetic.main.activity_main.*    

android toast message

Toast.makeText().show()   

kotlin random integer

Random.nextInt()

android drawable

<selector>

      <item>

            <shape>

                  <solid>

                  <corner>

android ImageView

resource 로 부터 이미지 가져오기 

ImageView.setImageResource()

android ListView

BaseAdapter , getItem, getCount, getItemId, getView

ListView.adapter = BaseAdapter를implement한obj

android view layout 

context객체.getSystemService()

android LayoutInflator 객체 얻는법

layoutInflator객체.inflate(Context.LAYOUT_INFLATER_SERVICE)

android activity 

다른 actvity로 이동

Intent, intent객체.putExtra(), startActivity() 

android Bundle activity Intent

intent에서 bundle data가져오기

intent객체.extras 는 Bundle 객체를 return. bundle객체.getString(”키이름”)

android ListView change delete update adapter

adapter객체.notifyDataSetChanged()

kotlin inner class access property

inner modifier

https://stackoverflow.com/a/45418262/3151712

android image drawable mipmap

한번에 다양한 크기의 같은 이미지 생성 프로그램

final_android_resizer

android GridView

ListView와 제작방법이 거의 동일하다.BaseAdapter , getItem, getCount, getItemId, getView. 단 GridView에 numColumns, columnWidth, horizontalSpacing 속성을 추가로 설정해야 한다.

GridView.adapter = BaseAdapter를implement한obj

android internet permission http

<uses-permission android:name = “android.permission.INTERNET”/>

android kotlin thread background

AsyncTask<> , doInBackground, onProgressUpdate, onPreExecute, onPostExecute

kotlin try catch

try{

}catch (ex:Exception){

}

android kotlin url connection

Url(url스트링) 하면 url객체를 얻을 수 있다. 

url객체.openConnection()하면 urlconnection객체를 얻을수있고 이를 HttpUrlConnection 객체나 HttpsUrlConnection객체로 타입전환할수 있다. HttpUrlConnection객체.connectTimeout() 을 통해 제한시간 설정가능

HttpUrlConnection.inputStream 을 통해 외부로부터 data를 받을수 있게 된다.

InputStream, InputStreamReader, BufferedReader 를 사용 한줄 한줄 읽어 온다.

android json 

JSONObect(스트링) , getJSONObect() 또는 getJSONArray()를 통해 한단계씩 들어가서 데이터를 가져온다.

android drawable background 

상태에 따른 스타일 바꾸기

<selector>  <item> <shape> <corner> <stroke> <solid> <padding>

<item android:state_pressed= “true”>

android firebase authentication analytics

Udemy kotlin android 강좌 

google firebase 사용방법 121 analytics ,122  authentication 매우 간단하고 이해하기 쉽다.

124 analytics

127 datastore database

130 3:00 addValueEventListener

android notification 

NotificationCompat.builder()

setDefault() setSmallIcon() setContentTitle() setContentText() setNumber()

context.getSystemService(context.NOTIFICATION_SERVICE)

Udemy kotlin android 강좌 132

android notification channel

NotificationChannel()

android image 사용 external storage camera permission

ActivityCompat.checkSelfPermission() 

requestPermissions()

onRequestPermissionsResult()

udemy 136 3:00 

android image file 디바이스에 있는 image file 가져오기

intent   intent.ACTION_PICK   android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI   startActivityForResult()

android image file content provider 사용자가 선택한 화일 가져오기

image

android filebase storage imageview에 있는 이미지를 압축해서 firebase storage에 올리기

FirebaseStorage   FirebaseStorage객체.getRefenceFromUrl()   

udemy 137

image

android google firebase authentication 

FirebaseAuth   createUserWithEmailAndPassword()   addOnCompleteListener()

FirebaseUser 

image

android picasso imageview image

udemy 140 9:00

android cloud messaging firebase

앱을 사용하는 다수의 사용자에게 message 보낼때사용. udemy 144

FirebaseMessaging.getInstance().subscribeToTopic()

manifest에 service추가 , meta-data 추가

Service class 작성  onMessageReceived()   

android kotlin variable element

참고) kotlin에서는 findById()과정없이 바로 element id통해 접근가능하다.

아래와 같이 사용해도 된다.

image

위와 같이 activity 안에 요소를 위한 variable을 만들고 view type을 명시적으로 해준경우 아래와 같이 <Button>을 해줘도 되고 안해도 된다.

image

그러나 아래와 같이 activity 안 어느 함수안에서 variable이 정의된경우 photoGalleryButton처럼 명시해주어야 한다.

image

android kotlin clicklistener listener lambda button

image

android kotlin photo picture intent

image

android photo gallery pick intent

image

android kotlin element id variable

image

kotlin에서는 findById()과정없이 바로 element id통해 접근가능하다.

android kotlin inputStream url http read buffer BufferedReader InputStreamReader

image

참고) BuffredReader에 대하여 https://www.baeldung.com/java-buffered-reader

android kotlin Toolbar ActionBar

아래에서는 toolbar는 activity_main layout에 있는 toolbar 의 id 이다.

image

android kotlin network 

network에 연결되었는지 확인하는 경우

image
image

android kotlin AlertDialog 

image
image

android kotlin bitmap url http 

image

android kotlin progress bar 

image

android kotlin button drawable background

gradientdrawable을 xml이 아닌 코드상에서 만드는 방법

image

android kotlin dp float drawable

gradientdrawable을 xml이 아닌 코드상에서 만들때 코너를 둥글게 만드는 경우 dp 사이즈를 설정해 주는데 이때 필요한 dp 값을 구하는 방법이다.

image

kotlin inner class nested 

https://stackoverflow.com/a/46730214/3151712

android kotlin listener anonymous class lambda sam

https://antonioleiva.com/lambdas-kotlin-android/

android kotlin listener anonymous class lambda sam

https://antonioleiva.com/listeners-several-functions-kotlin/

https://antonioleiva.com/lambdas-kotlin/

android kotlin draw onDraw

https://stackoverflow.com/questions/13640541/view-ondrawcanvas-c-versus-drawcanvas-c-in-android

android kotlin TextUtils isEmpty EditText가 비었는지 확인 축약형

https://stackoverflow.com/a/6290637/3151712

android kotlin bundle 만들기 축약형

https://medium.com/@programmerr47/creating-bundles-nicely-with-kotlin-1526fc173d01

옛날방법 https://stackoverflow.com/a/59957980/3151712

android kotlin invoke operator overload

https://stackoverflow.com/questions/45173677/invoke-operator-operator-overloading-in-kotlin

android studio json to kotlin plugin

json 내용을 보고 그에 맞는 kotlin classes를 자동으로 만들어 준다.

android studio – > preferences -> plugin -> json to kotlin 검색

kotlin reference member class ::

https://stackoverflow.com/a/51813211/3151712

kotlin by keyword delegate delegation

https://stackoverflow.com/a/57637851/3151712

==========================================================…original source : https://www.youtube.com/playlist?list=PLS1QulWo1RIYt4e0WnBp-ZjCNq8X0FX0J

image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image
image

자바, kotlin의 경우 여러개의 생성자를 정의할수 있다. 

image
image
image
image
image

==========================================================

.

.

.

module

image
image

위위의 myfunctions.py 모듈을 import로 가져와서 사용하는 것을 보여주고 있다.

==========================================================

.

.

.

image

위는 모듈이 다른 directory에 있을 때를 보여주고 있다.

image

위는 모듈이 다른 directory에 있을 때의 또 다른 방법을 보여주고 있다

image

==========================================================

.

.

.

image
image
image

==========================================================

.

.

.

image

==========================================================

.

.

.

image
image
image

==========================================================

.

.

.

하나의 class 가 하나의 class안에 들어가는 것을 composition 이라고 한다. 

image
image

==========================================================

.

.

.

image

==========================================================

.

.

.

exception

image
image
image

==========================================================

.

.

.

__name__   property 

image

==========================================================

.

.

.

writing file

image
image

==========================================================

.

.

.

reading files

image

아래와 같이 없는 화일의 이름으로 여는 경우 filenotfounderror가 발생한다.

image
image
image
image
image
image
image
image
image
image

==========================================================

.

.

.

json file 읽고 쓰기

image
image
image
image
image

==========================================================

.

.

.

iterator

image
image

==========================================================

.

.

.

generators

image
image
image

==========================================================

.

.

.

command line arguments

image
image
image

==========================================================

.

.

.

lambda 

image
image

==========================================================

.

.

.

nested function and closure

image
image
image
image
image

==========================================================

.

.

.

decorator

image
image
image
image
image
image

==========================================================

.

.

.

operator overloading

image
image
image
image

==========================================================

.

.

.

global, local, nonlocal 변수

original source : https://www.youtube.com/playlist?list=PLlxmoA0rQ-LwgK1JsnMsakYNACYGa1cjR

image

var 는 변수 , val은 상수 설정한다.

var의 경우 data type을 정해주거나 기본값을 설정함으로써 암시적으로 data type을 결정해야 한다.

image

==========================================================

.

.

.

class , function

image

==========================================================

.

.

.

string interpolation

image

==========================================================

.

.

.

package , import

아래와 같이 두 화일이 다른 package에 있는데 이쪽화일에서 저쪽 화일의 내용을 사용해야 하는 경우 아래와 같이 import를 사용한다.

class Person(var name: String)은 기본 contructor 기능을 수행하며 name property를 만든다.

image
image

==========================================================

.

.

.

data type

image
image

==========================================================

.

.

.

data type

image

==========================================================

.

.

.

string interpolation

image
image

==========================================================

.

.

.

range 

image
image

==========================================================

.

.

.

if statement, if expression

image
image

==========================================================

.

.

.

where statement, where expression

image
image
image

==========================================================

.

.

.

Loops, iterator, Loop statement

image
image
image

==========================================================

.

.

.

image
image

==========================================================

.

.

.

image
image

==========================================================

.

.

.

break statement

image
image
image
image

==========================================================

.

.

.

continue statement

image
image
image
image

==========================================================

.

.

.

function

image
image

==========================================================

.

.

.

function as expression

image

==========================================================

.

.

.

interoperability

image
image

==========================================================

.

.

.

image
image

==========================================================

.

.

.

kotlin 화일명에 kt를 붙인 것이 보통 class 이름으로 사용되는데 이를 변경하고자 하는 경우 아래 방법을 이용한다.

image
image

==========================================================

.

.

.

kotlin 화일과 java 화일이 각각 다른 package에 있는 경우 import를 이용한다.

image
image

==========================================================

.

.

.

default fuction and @JvmOverloads

image
image
image

==========================================================

.

.

.

named parameter

==========================================================

.

.

.

  • controller 이름 바꾸는 방법은 
image

안에서 controller 이름을 클릭후 변경가능

  • (간단하게 canvas의 요소를 controller코드상에서 outlet으로 연결하는 방법)

You’re going to make an outlet for this text field on the PlayerDetailsViewController using the Assistant Editor feature of Xcode. While still in the storyboard, open the Assistant Editor with the button from the toolbar (the one at the top right with two intertwining rings). It should automatically open on PlayerDetailsViewController.swift (if it doesn’t, use the jumpbar in the right hand split window to select PlayerDetailsViewController.swift).

Select the new text field and ctrl-drag(오르쪽클릭은 outlet,왼쪽클릭은 action) to the top of PlayersDetailViewController, just below the class definition. When the popup appears, name the new outlet nameTextField, and click Connect. Xcode will add the property to the PlayersDetailViewController class and connect it in the storyboard:

image

  • static cells: they only work in UITableViewController. Even though Interface Builder will let you add them to a table view inside a regular UIViewController, this won’t work during runtime.

  • (특정 요소를 first responder 로 만드는 방법 )

To avoid this, let a tap anywhere inside the row bring up the keyboard. OpenPlayerDetailsViewController.swift and add the following extension to the end of the file:

// MARK: - UITableViewDelegate
extension PlayerDetailsViewController {

  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if indexPath.section == 0 {
      nameTextField.becomeFirstResponder()
    }
  }
}

If the user taps the first cell, the app should activate the text field. There’s only one cell in the section so you only need to test for the section index. Making the text field the first responder will automatically bring up the keyboard.

https://www.raywenderlich.com/160519/storyboards-tutorial-ios-10-getting-started-part-2

  • 예를 들어 segue에 있는 done button을 클릭해서 특정 데이터를 저장하고 modal형태의 창을 닫는 경우 두가지 이벤트를 이용할수 있다. 버튼에 연결되어있는 action과 segue가 닫히기 전에 이벤트를 전달 받는 hook 포인트 prepare 가 있다. 

https://www.raywenderlich.com/160519/storyboards-tutorial-ios-10-getting-started-part-2

  • controller 이름 바꾸는 방법은 
image

안에서 controller 이름을 클릭후 변경가능

  • (간단하게 canvas의 요소를 controller코드상에서 outlet으로 연결하는 방법)

You’re going to make an outlet for this text field on the PlayerDetailsViewController using the Assistant Editor feature of Xcode. While still in the storyboard, open the Assistant Editor with the button from the toolbar (the one at the top right with two intertwining rings). It should automatically open on PlayerDetailsViewController.swift (if it doesn’t, use the jumpbar in the right hand split window to select PlayerDetailsViewController.swift).

Select the new text field and ctrl-drag(오르쪽클릭은 outlet,왼쪽클릭은 action) to the top of PlayersDetailViewController, just below the class definition. When the popup appears, name the new outlet nameTextField, and click Connect. Xcode will add the property to the PlayersDetailViewController class and connect it in the storyboard:

image

  • static cells: they only work in UITableViewController. Even though Interface Builder will let you add them to a table view inside a regular UIViewController, this won’t work during runtime.

  • (특정 요소를 first responder 로 만드는 방법 )

To avoid this, let a tap anywhere inside the row bring up the keyboard. OpenPlayerDetailsViewController.swift and add the following extension to the end of the file:

// MARK: - UITableViewDelegate
extension PlayerDetailsViewController {

  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if indexPath.section == 0 {
      nameTextField.becomeFirstResponder()
    }
  }
}

If the user taps the first cell, the app should activate the text field. There’s only one cell in the section so you only need to test for the section index. Making the text field the first responder will automatically bring up the keyboard.

https://www.raywenderlich.com/160519/storyboards-tutorial-ios-10-getting-started-part-2

  • 예를 들어 segue에 있는 done button을 클릭해서 특정 데이터를 저장하고 modal형태의 창을 닫는 경우 두가지 이벤트를 이용할수 있다. 버튼에 연결되어있는 action과 segue가 닫히기 전에 이벤트를 전달 받는 hook 포인트 prepare 가 있다. 

https://www.raywenderlich.com/160519/storyboards-tutorial-ios-10-getting-started-part-2