시큐어코딩 도구에서 널 포인터 역참조(파라미터) 부분에 에러 체크가 되는데 이유를 모르겠어요 ㅜㅜ
조회수 881회
package gw.techinmotion.uums;
import android.app.Activity; import android.graphics.Rect; import android.view.View; import android.view.ViewTreeObserver; import android.widget.FrameLayout;
public class AndroidBug5497Workaround {
public static void assistActivity(Activity activity){
new AndroidBug5497Workaround(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private AndroidBug5497Workaround(Activity activity){
// 이부분 오류 FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
possiblyResizeChildOfContent();
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent(){
int usableHeightNow = computeUsableHeight();
if(usableHeightNow != usableHeightPrevious){
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if(heightDifference > (usableHeightSansKeyboard/4)){
frameLayoutParams.height = usableHeightSansKeyboard-heightDifference;
}else{
frameLayoutParams.height = usableHeightSansKeyboard;
}
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight(){
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom-r.top);
}
}
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력