original source : https://youtu.be/l5vPmxyWboM

InputStream 의 method mark() , reset()에 대하여

http://esus.com/java-inputstream-mark-reset/

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

.

.

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

.

.

이 강의의 예제 프로젝트에서 ImageRequest는 이전 강의에서 만든 NetworkRequest를 extends해서 사용한다.

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

.

.

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

.

.

ListView사용시 재활용되는 view때문에 발생하는 문제를 보여주고 있다.

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

.

.

original source : https://youtu.be/RDI3ARcRYwI

이강의는 singleton , listener, factory 등등의 design pattern을 이용하는 것을 보여주고 있다. 이 방법을 통해 network manager를 만드는 것이 이 강의의 내용이다.

아래는 내가 유튜브에 남김 메모이다.

3:55  Handler.obtainMessage()는 message pool에서 재사용 가능한 message를 가져온다. 이는 Message.obtain()과 같은 기능을 한다.  참조) https://developer.android.com/reference/android/os/Handler.html#obtainMessage()
Handler.sendMessage() 를 통해 message queue에 넣으면 looper가 순차적으로 runnable, message를 처리하다가 해당 message를 만나게되면  Handler.handleMessage()를 호출하게 된다. 

 

5:35 여기서 network 작업을 다른 thread에서 하고 있는 것을 가정한다. network작업 결과가 성공적이면 public void sendSuccess()를 호출하고 실패하면 public void sendFail()를 호출한다. 각각의 함수는 mHandler.obtainMessage()를 통해 각각에 필요한 재사용가능한 message를 main thread에 있는 message pool에서 가져오고 mHandler.sendMessage()를 통해 message queue에 올려 놓는다. 그리고 looper에 의해 순서가 되면 mHandler.handleMessage()가 호출된다. 

 

9:30 에서 나오는 NetworkRequest class는 실제 android에서 제공하는 class가 아니고 이 강의에서 설명을 위해서 만들어진 class이다.

original source : https://youtu.be/48eE_O0p8Zc

이 강의는 프로그래밍의 여러 design pattern 중에서 android에서 유용하게 쓰일수 있는 singleton, threadpool, listener 의 사용법을 보여준다.
이 강의는 networkmanager를 만드는 것을 예로 들고 있다.

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

.

.

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

.

.

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

.

.

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

.

.

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

.

.

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

.

.

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

.

.

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

.

.

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

.

.

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

.

.

참고로 factory pattern은 하나의 factory class를 통해 여러 다른 타입의 하위 클래스를 상황에 따라 맞게 생성할수 있다. 예를 들어 X를 extends한 x1 , x2클래스가 있는 경우 factory X를 통해 상황에 따라 x1, x2를 생성할수 있다.  

original source : https://youtu.be/KPofPZLTuMc

keyevent는 실제 물리적인 버튼에 의해 발생한 이벤트를 말한다. 예를 들면 음량버튼

motionevent는 터치이벤트를 말한다.

image
image

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

.

.

image
image

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

.

.

image
image

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

.

.

image
image

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

.

.

MotionEvent를 통해 id를 얻을 수도 있고 index를 얻을수도 있다.

MotionEvent.getPointerId()

MotionEvent.findPointerIndex()

각각의 터치는 id를 가지며 id를 통해 index를 얻고 index를 통해 x, y 좌표를 얻을수 있다.

image
image
image

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

.

.

image

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

.

.

image
image

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

.

.

image
image

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

.

.

image

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

.

.

하나의 화면에서 스크롤기능과 클릭이 합쳐진 경우

예를 들어 listview를 스크롤하는 경우. view group에서 먼저 처리할 이벤트를 처리해야 하는 경우가 있다. 

image
image

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

.

.

image
image
image

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

.

.

image

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

.

.

image
image

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

.

.

image

original source : https://youtu.be/KPofPZLTuMc

keyevent는 실제 물리적인 버튼에 의해 발생한 이벤트를 말한다. 예를 들면 음량버튼

motionevent는 터치이벤트를 말한다.

image
image

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

.

.

image
image

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

.

.

참고자료) https://stackoverflow.com/a/42040411/3151712

참고자료) https://medium.com/@arj.sna/multi-touch-in-android-c87031d106b3

Multi-Touch in android was available since Android 2.0. When more than one finger touches the screen multi-touch gesture happens and android provide various apis to handle these gestures. Lets start with the basic event handling for single finger on the screen

public boolean onTouchEvent(MotionEvent ev){ 
 final int action = ev.getAction();
 switch(action) {
    case MotionEvent.ACTION_DOWN: {
       Log.i("Event handled ", "Action finger down"); break;
    }
    case MotionEvent.ACTION_UP: {
      Log.i("Event handled ", "Action finger up");
      break;
    }
 return true;
}

The above is the one of many methods of handling touches which logs touch down and up of single finger. This work fine as long as we don’t need to handle multiple fingers. But in many cases handling single finger events in not sufficient. For handling multi-touch we need to handle the below two additional events.

ACTION_POINTER_DOWN – MotionEvent.ACTION_POINTER_DOWN is the event triggered whenever the secondary pointer touches the screen. If there is already a pointer(finger) on the screen and one more pointer goes in contact with the screen, ACTION_POINTER_DOWN event is triggered. For all the next coming pointers the ACTION_POINTER_DOWN is triggered. MotionEvent.ACTION_DOWN will be triggered only for the first pointer coming in contact with the screen.

ACTION_POINTER_UP – MotionEvent.ACTION_POINTER_UP is the event triggered when a pointer goes up and there in yet another pointer still in contact with the screen. The same event is triggered for all pointer going up till the last pointer and MotionEvent.ACTION_UP will be triggered for the last pointer leaving the screen.

The next two things we should know to keep track of each pointer is are Pointer Index and Pointer ID. Lets see what they are and how they help us in handling multi-touch.

Index – In a MotionEvent object, the pointer details are stored in array. So, the Index of a pointer is its position in that array. From this we can infer that pointer index in not persistent across the event. To put that with an example, when a first pointer touches the screen, it will be the first object in array, with pointer index 0. When second pointer comes, it will be stored in index 1. Now when the pointer with index 0 goes up, the position of pointer in array is rearranged, which puts the second pointer which is currently stays on screen in index 0.

ID – While the pointer index is non persistent, to identify the pointers across events of an entire gesture, Pointer IDcomes in handy. Pointer ID is unique ID mapping to the pointer which stays persistent always. So in the example discussed for Index, even when the position of pointer in array changes, its pointer id remains same. That makes the difference between Index and ID.

image
image

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

.

.

image
image

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

.

.

MotionEvent를 통해 id를 얻을 수도 있고 index를 얻을수도 있다.

MotionEvent.getPointerId()

MotionEvent.findPointerIndex()

각각의 터치는 id를 가지며 id를 통해 index를 얻고 index를 통해 x, y 좌표를 얻을수 있다.

image
image
image

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

.

.

image

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

.

.

image
image

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

.

.

image
image

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

.

.

image

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

.

.

하나의 화면에서 스크롤기능과 클릭이 합쳐진 경우

예를 들어 listview를 스크롤하는 경우. view group에서 먼저 처리할 이벤트를 처리해야 하는 경우가 있다. 

image
image

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

.

.

image
image
image

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

.

.

image

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

.

.

image
image

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

.

.

image

original source : https://youtu.be/4KyUGia25Lk

image
image

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

.

.

image

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

.

.

image

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

.

.

image
image

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

.

.

image

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

.

.

프로그래밍 기법 OOP에서 obj의 data는 obj스스로 처리하는 것을 좋은 방법으로 생각한다. 그러므로 obj의 내부 json data를 obj가 JSONObjectHandler를 implement하고 obj가 스스로 처리하는 방법을 추천한다.

image

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

.

.

image
image
image
image
image

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

.

.

image