コード例 #1
0
 /** 更新餐厅信息 */
 private void updateInfo() {
   ImageFetcher.asInstance()
       .loadRoundedCorner(mRestaurant.getImage(), mRestaurantImageView, ScreenUtils.dip2px(1));
   mScoreCountView.setText(mRestaurant.getGrade());
   mSaleCountView.setText(mRestaurant.getSale());
   setTitle(mRestaurant.getName());
 }
コード例 #2
0
    @Override
    protected View newView(int viewType) {
      switch (viewType) {
        case ITEM_TYPE_TWO:
          View view_double =
              LayoutInflater.from(getContext()).inflate(R.layout.listview_item_dish, null);
          View itemLeft = view_double.findViewById(R.id.app_list_item_left);
          View itemRight = view_double.findViewById(R.id.app_list_item_right);
          setViewStatues(itemLeft);
          setViewStatues(itemRight);
          int itemViewWidth = (ScreenUtils.getScreenWidthInt() - 3 * ScreenUtils.dip2px(8)) / 2;
          ScreenUtils.resizeView(
              itemLeft.findViewById(R.id.app_dish_cover_group), itemViewWidth, 1f);
          ScreenUtils.resizeViewOfWidth(
              itemLeft.findViewById(R.id.app_dish_title_group), itemViewWidth);

          ScreenUtils.resizeView(
              itemRight.findViewById(R.id.app_dish_cover_group), itemViewWidth, 1f);
          ScreenUtils.resizeViewOfWidth(
              itemRight.findViewById(R.id.app_dish_title_group), itemViewWidth);

          ScreenUtils.reMargin(
              itemLeft.findViewById(R.id.app_dish_restaurant_group), 0, 0, 0, 75, true);
          ScreenUtils.reMargin(
              itemRight.findViewById(R.id.app_dish_restaurant_group), 0, 0, 0, 75, true);

          View coverL = itemLeft.findViewById(R.id.app_dish_content);
          ScreenUtils.resizeView(coverL, itemViewWidth, 251.5f / 172.5f);

          View coverR = itemRight.findViewById(R.id.app_dish_content);
          ScreenUtils.resizeView(coverR, itemViewWidth, 251.5f / 172.5f);
          return view_double;
        case ITEM_TYPE_ONE:
        default:
          View view_single =
              LayoutInflater.from(getContext()).inflate(R.layout.view_dish_big, null);
          setViewStatues(view_single);
          int itemViewWidthBig = ScreenUtils.getScreenWidthInt() - 2 * ScreenUtils.dip2px(8);
          View content = view_single.findViewById(R.id.app_dish_content);
          ScreenUtils.resizeView(content, itemViewWidthBig, 257 / 355f);
          return view_single;
      }
    }
コード例 #3
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (view != null) {
      return view;
    }
    view = inflater.inflate(R.layout.fragment_restaurant_detail, null);

    mPullToZoomListView = (PullToZoomListView) view.findViewById(R.id.app_restaurant_detail_list);
    mPullToZoomListView.setHeaderViewSize(
        ScreenUtils.getScreenWidthInt(), (int) (210f * ScreenUtils.getScreenWidthInt() / 375f));
    mPullToZoomListView.setOnListViewZoomListener(
        new PullToZoomListView.OnListViewZoomListener() {
          @Override
          public void onHeaderZoom(float f) {
            Rect categorySize = ScreenUtils.getViewSize(mCategoryLayout);
            Rect categoryTitlebarSize = ScreenUtils.getViewSize(mTitleBarCategoryLayout);

            if (categoryTitlebarSize.top > 0 && categorySize.top > 0) {
              if (mAnimators.isEmpty()) {
                mAnimatorDuration = categorySize.top - categoryTitlebarSize.top;
                defaultAnimationTime = (int) mAnimatorDuration;
                createAnimation(mAnimatorDuration);
              }

              int offset = categorySize.top - categoryTitlebarSize.top;
              if (offset <= 0) {
                // 显示
                mTitleBarCategoryLayout.setVisibility(View.VISIBLE);
                mCategoryLayout.relationWith(null);
                mTitleBarCategoryLayout.relationWith(mCategoryLayout);
                getTitleBar().enableBottomDiv(true);
              } else {
                mTitleBarCategoryLayout.setVisibility(View.GONE);
                mTitleBarCategoryLayout.relationWith(null);
                mCategoryLayout.relationWith(mTitleBarCategoryLayout);
                getTitleBar().enableBottomDiv(false);
              }
              updateZoomAnimator(mAnimatorDuration - offset);
            }
          }
        });
    mHeadView = mPullToZoomListView.getHeaderView();
    mHeadImageView = (ImageView) mHeadView.findViewById(R.id.app_list_head_image);
    mHeadImageView.setImageResource(R.drawable.app_bg_restaurant);

    mNoticeView = (FrameLayout) mHeadView.findViewById(R.id.app_list_head_notice);

    mRestaurantImageView = (ImageView) mHeadView.findViewById(R.id.app_restaurant_detail_image);
    mScoreCountView = (TextView) mHeadView.findViewById(R.id.app_restaurant_detail_score_title);
    mScoreDescView = (TextView) mHeadView.findViewById(R.id.app_restaurant_detail_score_desc);
    mHeadView
        .findViewById(R.id.app_restaurant_detail_score)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                // 用户评论
                LogGather.onEventDishRestaurantDetailGoEvaluate();
                Bundle bundle = new Bundle();
                bundle.putString(DishRestaurantCommentFragment.EXTRA_RESTAURANT_ID, mRestaurantId);
                next(DishRestaurantCommentFragment.class, bundle);
              }
            });
    mSaleCountView = (TextView) mHeadView.findViewById(R.id.app_restaurant_detail_sale_title);
    mHeadView
        .findViewById(R.id.app_restaurant_detail_sale)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                // 热门销量
                LogGather.onEventDishRestaurantDetailGoSale();
                Bundle bundle = new Bundle();
                bundle.putString(DishHotSaleListFragment.EXTRA_RESTAURANT_ID, mRestaurantId);
                next(DishHotSaleListFragment.class, bundle);
              }
            });

    mRestaurantNoticeView = view.findViewById(R.id.app_restaurant_detail_notice);
    mRestaurantNoticeContentView =
        (TextView) view.findViewById(R.id.app_restaurant_detail_notice_content);

    mTitleBarCategoryLayout =
        (DishCategoryView) view.findViewById(R.id.app_restaurant_detail_anchor);
    mCategoryLayout = (DishCategoryView) inflater.inflate(R.layout.view_category_order, null);
    mCategoryLayout.relationWith(mTitleBarCategoryLayout);
    mCategoryLayout.setHandler(
        new DishCategoryView.OnCategoryOrderHandler() {
          @Override
          public void onOrderItemClick(int position) {
            requestDishList();
          }

          @Override
          public void onCategoryItemClick(Tags tag) {
            requestDishList();
          }
        });
    int default_menu_icon =
        default_dish_mode.equals(DishDetailAdapter.DISH_MODE_SINGLE)
            ? R.drawable.app_ic_layout_mode_small
            : R.drawable.app_ic_layout_mode_big;
    mTitleBarCategoryLayout.getmOrderByChooseView().setSwitchImg(default_menu_icon);
    mCategoryLayout.getmOrderByChooseView().setSwitchImg(default_menu_icon);
    mTitleBarCategoryLayout
        .getmOrderByChooseView()
        .setOnMenuItemClick(
            new DishOrderByView.OnMenuItemClick() {
              @Override
              public void OnClick(View v) {
                changeAdapterMode(v);
              }
            });
    mCategoryLayout
        .getmOrderByChooseView()
        .setOnMenuItemClick(
            new DishOrderByView.OnMenuItemClick() {
              @Override
              public void OnClick(View v) {
                changeAdapterMode(v);
              }
            });
    return view;
  }