Ejemplo n.º 1
0
 private void arrowlistener() {
   int width = arrowicon.getMeasuredWidth();
   int height = arrowicon.getMeasuredHeight();
   LogUtils.D("onClick" + width + " " + height);
   Matrix matrix = new Matrix();
   count++;
   matrix.postRotate(180 * count, width / 2, height / 2);
   arrowicon.setImageMatrix(matrix);
   if (count % 2 != 0) {
     list_title.setVisibility(View.VISIBLE);
     list_content.setVisibility(View.VISIBLE);
     View view = (View) mViewPager.getParent();
     Bitmap bitmap =
         BitmapUtils.shot(
             getView(),
             (int) view.getX(),
             (int) view.getY(),
             mViewPager.getMeasuredWidth(),
             mViewPager.getMeasuredHeight());
     if (bitmap != null)
       list_content.setBackground(
           new BitmapDrawable(BitmapUtils.blurBitmap(bitmap, getActivity())));
     //                    list_content.setBackground(new
     // BitmapDrawable(BitmapUtils.compressBmpFromBmp(bitmap)));
     mItemHScrollView.setVisibility(View.GONE);
     mViewPager.setVisibility(View.GONE);
   } else {
     list_title.setVisibility(View.GONE);
     list_content.setVisibility(View.GONE);
     list_content.setBackground(null);
     mItemHScrollView.setVisibility(View.VISIBLE);
     mViewPager.setVisibility(View.VISIBLE);
   }
 }
Ejemplo n.º 2
0
  private void initViewPager(View root) {
    mViewPager = (CatchTouchViewPager) root.findViewById(R.id.content);
    mViewPager.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                mItemHScrollView.touchDown();
                break;
              case MotionEvent.ACTION_UP:
                mItemHScrollView.touchUp();
                break;
            }
            return false;
          }
        });
    mViewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {
          float lastOffset;
          boolean isScrolling = false;

          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            //                if (Math.abs(lastOffset - positionOffset) < 0.005f) return;

            if (lastOffset == 0) {
              lastOffset = positionOffset;
              return;
            }
            boolean toRight = false;
            if (lastOffset > positionOffset) { // to right
              toRight = true;
            } else {
              toRight = false;
            }
            mItemHScrollView.onPageScrolled(position, convert(positionOffset), toRight);
            lastOffset = positionOffset;
          }

          @Override
          public void onPageSelected(int position) {
            LogUtils.D("onPageSelected " + position);
            mItemHScrollView.setSelectedItem(position);
            lastOffset = 0;
          }

          @Override
          public void onPageScrollStateChanged(int state) {
            if (state == 1) {
              isScrolling = true;
            } else {
              isScrolling = false;
            }
          }
        });
  }
Ejemplo n.º 3
0
 private void handleType(JSONArray result) {
   //        LogUtils.D(response.result.toString());
   fragmentList = new ArrayList<Fragment>();
   String[] typenames = new String[result.length()];
   for (int i = 0; i < result.length(); i++) {
     try {
       JSONObject jsonObject = (JSONObject) result.get(i);
       int typeid = jsonObject.getInt("ID");
       String typename = jsonObject.getString("typename");
       fragmentList.add(new ArticleListFragment(typeid, typename, i));
       typenames[i] = typename;
     } catch (JSONException e) {
       e.printStackTrace();
     }
   }
   FragmentActivity fragmentActivity = getActivity();
   mViewPager.setAdapter(
       new MyFragmentPagerAdapter(fragmentActivity.getSupportFragmentManager(), fragmentList));
   mViewPager.setCurrentItem(0);
   mItemHScrollView.setAdpater(new TabButtonAdapter(typenames));
   lanmu.setAdapter(new LanmuAdapter(typenames));
 }