private void initGallery() { imgList = new ArrayList<>(); imgList.add(R.drawable.sy_yjqb); imgList.add(R.drawable.xb); restaurant_orderseat_img_container = (LinearLayout) mView.findViewById(R.id.restaurant_orderseat_img_container); ipaAdapter = new GalleryAdapter(activity, imgList, restaurant_orderseat_img_container); restaurant_orderseat_image.setAdapter(ipaAdapter); restaurant_orderseat_image.setFocusable(true); restaurant_orderseat_image.startTimer(3000); intent = new Intent(); intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION); restaurant_orderseat_image.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position % imgList.size()) { case 0: intent.putExtra("title", "去钓鱼岛"); intent.setClass(getActivity(), WholeBookActivity.class); startActivity(intent); break; case 1: intent.putExtra("title", "去钓鱼岛"); intent.setClass(getActivity(), WholeBookActivity.class); startActivity(intent); break; } } }); restaurant_orderseat_image.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { position = position % imgList.size(); if (imgList.size() > 1) { // 修改上一次选中项的背景 ImageView preSelImg = (ImageView) restaurant_orderseat_img_container.findViewById(preSelImgIndex); preSelImg.setImageResource(R.drawable.ic_focus); // 修改当前选中项的背景 ImageView curSelImg = (ImageView) restaurant_orderseat_img_container.findViewById(position); curSelImg.setImageResource(R.drawable.ic_focus_green_select); // text_hotelName.setText(selIndex + ""); preSelImgIndex = position; } } @Override public void onNothingSelected(AdapterView<?> parent) {} }); }
/** * ********************************************** * * @return void 返回类型 * @throws @Title: init @Description: TODO(初始化数据) 设定文件 * @date 2014-11-19 *********************************************** */ @InjectInit public void init() { db = Ioc.getIoc().getDb("/sdcard/MTM/", Constants.APP_DATABASE); dataList = new ArrayList<HashMap<String, String>>(); initView(); mImageFetcher = new ImageDownloader(getActivity(), 300); mImageFetcher.setLoadingImage(R.drawable.default_load_image); eventBus.register(this, "onEventPostRoomList"); // 设置list列表间距 srla = new ConditionsRoomAdapter( activity, listview_roomlist, dataList, R.layout.reservation_screeningroom_item); listview_roomlist.setAdapter(srla); // 这里是设置里面的文字 可以不设置 默认有 PullToRefreshManager.getInstance().setRelease_label("松开后刷新"); PullToRefreshManager.getInstance() .setUpdateTime(org.apache.http.impl.cookie.DateUtils.formatDate(new Date(), "yyyy-MM-dd")); showDialog(); ajaxRoomList(1); ajaxPOST(); gallery_hotel.setOnItemClickListener( new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { startActivity(new Intent(getActivity(), HotelViewPagerActivity.class)); } }); search_layout.setVisibility(View.GONE); }
/** * ********************************************** * * @param r 设定文件 * @return void 返回类型 * @throws @Title: fastResult @Description: (酒店楼宇接口 返回) * @date 2014-11-19 *********************************************** */ @InjectHttpOk(value = {111}) protected void fastResult(ResponseEntity r) { System.out.println(r.getStatus()); switch (r.getStatus()) { case FastHttp.result_ok: if (ResultParse.reservationIsResultOK(r, activity)) { imgList = Handler_Json.JsonToCollection(r.getContentAsString()); // InitFocusIndicatorContainer(); // initGallery(); ipaAdapter = new ImagePagerAdapter(activity, imgList, indicator_container); gallery_hotel.setAdapter(ipaAdapter); ipaAdapter.notifyDataSetChanged(); gallery_hotel.setFocusable(true); } break; case FastHttp.result_net_err: Toast.makeText(activity, "网络异常 ,请检查您确保开启无线网络", Toast.LENGTH_SHORT).show(); break; } }
@InjectInit private void init() { int width = activity.getResources().getDisplayMetrics().widthPixels; LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(width, width / 3); FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(width, width / 3); RelativeLayout linearLayout3 = (RelativeLayout) mView.findViewById(R.id.linearLayout3); imageView6 = (ImageView) mView.findViewById(R.id.imageView6); restaurant_orderseat_image = (IMGGallery) mView.findViewById(R.id.restaurant_orderseat_image); restaurant_orderseat_image.setLayoutParams(layoutParams2); RelativeLayout.LayoutParams layoutParams3 = new RelativeLayout.LayoutParams(width, width / 3); imageView6.setLayoutParams(layoutParams3); linearLayout3.setLayoutParams(layoutParams1); eventBus = EventBus.getDefault(); home_page = (ImageView) mView.findViewById(R.id.home_page); jzyd = (RelativeLayout) mView.findViewById(R.id.jzyd); jzyd_layout = (RelativeLayout) mView.findViewById(R.id.jzyd_layout); jzyd_layout.setOnClickListener(onClickListener); OnEventChange(); // 初始化轮询 initGallery(); }
@Override public void onDestroy() { super.onDestroy(); gallery_hotel.destroy(); MapVo.remove("conditions"); }