@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getActivity().registerReceiver(receiver, receiverFilter); View root = inflater.inflate(R.layout.activity_index, container, false); FrameLayout layerLayout = (FrameLayout) root.findViewById(R.id.layer); layerLayout.setOnTouchListener(controller); barTitle = (TitleBar) root.findViewById(R.id.titlebar); barTitle.getTitle().setText(R.string.activity_title); barTitle.getLeftButton().setOnClickListener(controller); barTitle.getLeftButton().setBackgroundResource(R.drawable.nav_btnselector); barTitle.getRightButton().setText(R.string.search); barTitle.getRightButton().setVisibility(View.VISIBLE); barTitle.getRightButton().setOnClickListener(controller); circleMsgTip(); pager = (IndexViewPager) root.findViewById(R.id.pager); pager.setPagerViewLayoutParams(); pager.setVisibility(View.GONE); btnHuWai = root.findViewById(R.id.huwai); btnHuWai.setOnClickListener(controller); btnShiNei = root.findViewById(R.id.shinei); btnShiNei.setOnClickListener(controller); // btnLvYou = root.findViewById(R.id.lvyou); // btnLvYou.setOnClickListener(controller); btnXianShang = root.findViewById(R.id.xianshang); btnXianShang.setOnClickListener(controller); fujin = (ImageView) root.findViewById(R.id.fujin); fujin.setOnClickListener(controller); controllerFloat = new FloatWindowController(layerLayout); String res = App.CACHE.read(CACHE_KEY); if (!TextUtils.isEmpty(res)) { String today = res.substring(0, 8); res = res.substring(8); if (today.equals(controller.today.toString())) { try { pager.onSuccess(res); pager.notifyDataSetChanged(); } catch (Exception e) { ELog.e("Exception:" + e.getMessage()); e.printStackTrace(); } } } return root; }
@Override public void onDestroyView() { ELog.i(""); getActivity().unregisterReceiver(receiver); pager.stopPlay(); super.onDestroyView(); }
@Override public void onStart() { if (pager != null) { pager.stopPlay(); } super.onStart(); }
@Override public void onStop() { ELog.i(""); pager.stopPlay(); super.onStop(); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { if (!NetworkType.NONE.equals(App.getNetworkType())) { pager.obtainBanner(App.PREFS.getUid(), controller.getObtainBannerDataListener()); } }