以下是一个launcher主函数, 请问(我是初学者),从字面上看,主函数中的几个函数作用是什么?
请说具体一些,给高分,分还可以加.
setContentView(R.layout.activity_main); //调用布局文件
registerLauncherReceivers(); //注册广播接收者, 这有何具体作用?
initNotification(); //这个函数功能?
initView(); //初始化界面?
initData(); //初始化数据?
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);
registerLauncherReceivers();
initNotification();
initView();
initData();
}
private void initNotification() {
mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
mLoadingWakeLock = mPowerManager.newWakeLock(
PowerManager.ACQUIRE_CAUSES_WAKEUP
| PowerManager.SCREEN_BRIGHT_WAKE_LOCK,
“Lancher::Loading”);
mLoadingWakeLock.setReferenceCounted(false);
mNotification = new NotificationUIManager(this, mPowerManager,
mLoadingWakeLock);
}
private void initData() {
adapterBlue = BluetoothAdapter.getDefaultAdapter();
if (adapterBlue == null
|| adapterBlue.getAddress() == null
|| BluetoothAdapter.getDefaultAdapter().getState() == BluetoothAdapter.STATE_OFF) {
mQrcodeView.setImageResource(R.drawable.theme_error);
mQrcodeView.setVisibility(View.VISIBLE);
mClearbtn.setVisibility(View.INVISIBLE);
mQrcodeView.setImageResource(R.drawable.theme_error);
} else {
mQrcodeView.setImageBitmap(Utilities.createQRImage(adapterBlue
.getAddress()));
}
mHScrollLayout.setListener(new ScrollStateListener() {
@Override
public void stateChanged(int state) {
}
@Override
public void pageChanged(int currentPage) {
currPageH = currentPage;
Log.i(TAG, “——————>currPageH:” + currPageH);
}
});
mVScrollLayout.setListener(new ScrollStateListener() {
@Override
public void stateChanged(int state) {
if (state == 1) {
// mHScrollLayout.setScrollEnable(false);
}
}
@Override
public void pageChanged(int currentPage) {
currPageV = currentPage;
Log.i(TAG, “——————>currPageV:” + currPageV);
// setHScrollEnable(currentPage);
}
});
mNotification.setEmptyView(this.findViewById(R.id.empty));
homeLayout.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (clockEditMode)
return false;
enterEditMode();
return false;
}
});
mClearbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showExitNotiAlert();
}
});
}
private void initView() {
mFrameLayout = (FrameLayout) findViewById(R.id.launcher_bg);
mHScrollLayout = (HScrollLayout) findViewById(R.id.rootview);
mVScrollLayout = (VScrollLayout) findViewById(R.id.vscroll);
mQrcodeView = (ImageView) findViewById(R.id.qrcodeview);
mQrcodeView.setVisibility(View.VISIBLE);
topLayout = (LinearLayout) findViewById(R.id.quic_settings_layout);
bottomLayout = (LinearLayout) findViewById(R.id.music_settings_layout);
homeLayout = (RelativeLayout) findViewById(R.id.home_screen);
notificationLayout = (RelativeLayout) findViewById(R.id.notification);
mClearbtn = (ImageView) findViewById(R.id.clearbutton);
notificationLayout.addView(mNotification.getListView());
mHScrollLayout.setLeftView(mNotification.getListView());
mHScrollLayout.requestLayout();
mVScrollLayout.requestLayout();
}