@Override
public void onStart() {
super.onStart();
Bundle bundle=getArguments();
int row=bundle.getInt("row");
int index=bundle.getInt("index");
Log.i("갤러리",index+"시작,"+(gallery==null));
if(row!=this.row){
this.row=row;
column=bundle.getInt("column");
}
if(gallery!=null)Test();
}
GalleryFragment fragment=fragments[index];
Bundle arg=fragment.getArguments();
Bundle bundle= arg==null? new Bundle(): arg;
bundle.putInt("row",row);
bundle.putInt("column",column);
bundle.putInt("index",index);
fragment.setArguments(bundle);
if(startCall){
Log.i("갤러리"+index,"재전송");
fragment.onStart();
}
}
public void onStart() {
super.onStart();
Bundle bundle=getArguments();
int row=bundle.getInt("row");
int index=bundle.getInt("index");
Log.i("갤러리",index+"시작,"+(gallery==null));
if(row!=this.row){
this.row=row;
column=bundle.getInt("column");
}
if(gallery!=null)Test();
}
이게 타깃 Fragment onStart함수고
GalleryFragment fragment=fragments[index];
Bundle arg=fragment.getArguments();
Bundle bundle= arg==null? new Bundle(): arg;
bundle.putInt("row",row);
bundle.putInt("column",column);
bundle.putInt("index",index);
fragment.setArguments(bundle);
if(startCall){
Log.i("갤러리"+index,"재전송");
fragment.onStart();
}
}
이쪽은 해당 Fragment 관리하는 Adapter에서 실행하는 함수임
근데 이게 존나 엿같이 웃긴게
회전등으로 Fragment를 다시 만들어야할 상황이옴
-> 갤러리 0, 1 만들어짐. 이때는 하위 View가 존재.
-> 이후 Adapter에서 함수 호출해서 갤러리 0,1의 onStart함수만 다시 실행
-> 이때는 하위 View가 없음
뭔데 대체; Adapter함수가 먼저 실행되면 onCreateView 실행전이라고 생각이라도 하지
null여부 따지는 View는 대놓고 레이아웃에 장착되잇는 놈인데 GC가 그 사이에 쓸어갓을리도 없고
Log.i랑 system.out.print랑 뭔차이??
onStart는 직접 부르는 거 아니다
그게 그거인걸로 아는데 안드로이드스튜디오는 sysout쳐도 치환안해주더만
gallery가 먼데 도대체
GridLayout
setFragmentBundle은 누가 부르고?
adapter 생성자가 부름?
Fragment1-> Adapter-> gallery있는 Fragment인데, Fragment1의 레이아웃 상태가 바뀌면 (onLayoutChanged 호출) 함수 처리하고 끝에 adapter.setFragmentBundle 부름
View는 액티비티 컨텍스트 쓰는 놈이라 GC가 쓸어가도록 만들어놔야 하는데 GC처리 안 되면 돌릴 때마다 메모리 릭 남
근데 글싸고나서 생각해보니 Fragment1에서 이걸 처리하는게 아니라 gallery있는 Fragment에서 직접 처리하면 되지않나 싶어서 고치는중