@Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout containing a title and body text.
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.estadistica_view, container, false);

    int idEstadistica = this.mPageNumber;

    // Titulo y descripcion de estadistica
    TextView tituloEstadistica = (TextView) rootView.findViewById(R.id.TxtTituloEstadistica);
    TextView descEstadistica = (TextView) rootView.findViewById(R.id.TxtDescEstadistica);

    tituloEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getTitulo());
    descEstadistica.setText(RelacionEstadisticas.getRelacion().get(idEstadistica).getDescripcion());

    rootView.addView(
        new EstadisticaViewLayout(Utilidades.getAppContext())
            .getView(RelacionEstadisticas.getRelacion().get(idEstadistica)));
    // }
    // catch (Exception e)
    // {
    //	Toast.makeText(Utilidades.getAppContext(), "error: " + e.getLocalizedMessage(),
    // Toast.LENGTH_LONG).show();
    //	Log.e("ERROR", e.getLocalizedMessage());
    // }
    // Set the title view to show the page number.
    /*((TextView) rootView.findViewById(android.R.id.text1)).setText(
    getString(R.string.title_template_step, mPageNumber + 1));*/

    return rootView;
  }
Пример #2
0
  private void flipPage(final boolean forward) {
    if (!current.isFirstPage()) flipStarted = true;

    this.previousDirection = this.forward;
    this.forward = forward;

    if (!forward) decreasePageNo();

    int nextPageIndex = forward ? currentPageIndex + 1 : currentPageIndex;
    System.out.println("debug flip");
    if (currentPageIndex == -1 && forward) { // we are first timer
      currentPageIndex++;
      container.addView(current, pageViewLayoutParamsFront);
      slideToNextPageAsynchronized();
    } else if (nextPageIndex > 0) {

      if (current.isLastPage() && forward) {
        finishActivity();
      }
      slideToNextPageAsynchronized();
    } else {
      if (pageIndexView.isHasUpdate()) {
        this.reload();
        return;
      } else {
        finishActivity();
      }
    }
    System.out.println("debug flip done");
  }
Пример #3
0
  private void FullSwipeTrigger() {
    Log.d("FUll Swipe trigger call", "Works**********************" + mDismissAnimationRefCount);
    old_mDownView = mDownView;
    int width;
    if (SwipeType == Single || SwipeType == Dismiss) {
      width = textwidth;
      if (SwipeType == Dismiss) ++mDismissAnimationRefCount;
    } else {
      width = largewidth;
    }
    mDownView
        .animate()
        .translationX(-width)
        .setDuration(300)
        .setListener(
            new AnimatorListenerAdapter() {
              @Override
              public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                moptionsDisplay = true;

                stagged_position = temp_position;
                mDownView_parent_txt1.setOnTouchListener(new touchClass());
                //                        if(SwipeType==Double)
                //                            mDownView_parent_txt2.setOnTouchListener(new
                // touchClass());

              }

              @Override
              public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
              }
            });
  }
Пример #4
0
    public View getView(int position, View convertView, ViewGroup parent) {
      final View view =
          (convertView != null)
              ? convertView
              : LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.bookmark_item, parent, false);
      final ImageView imageView = (ImageView) view.findViewById(R.id.bookmark_item_icon);
      final TextView textView = (TextView) view.findViewById(R.id.bookmark_item_text);
      final TextView bookTitleView = (TextView) view.findViewById(R.id.bookmark_item_booktitle);

      final Bookmark bookmark = getItem(position);
      if (bookmark == null) {
        imageView.setVisibility(View.VISIBLE);
        imageView.setImageResource(R.drawable.ic_list_plus);
        textView.setText(ZLResource.resource("bookmarksView").getResource("new").getValue());
        bookTitleView.setVisibility(View.GONE);
      } else {
        imageView.setVisibility(View.GONE);
        textView.setText(bookmark.getText());
        if (myCurrentBook) {
          bookTitleView.setVisibility(View.GONE);
        } else {
          bookTitleView.setVisibility(View.VISIBLE);
          bookTitleView.setText(bookmark.getBookTitle());
        }
      }
      return view;
    }
Пример #5
0
  private void initValue(Activity activity) {
    this.activity = activity;
    leftMenuItems = new ArrayList<ResideMenuItem>();
    rightMenuItems = new ArrayList<ResideMenuItem>();
    ignoredViews = new ArrayList<View>();
    viewDecor = (ViewGroup) activity.getWindow().getDecorView();
    viewActivity = new TouchDisableView(this.activity);

    View mContent = viewDecor.getChildAt(0);
    viewDecor.removeViewAt(0);
    viewActivity.setContent(mContent);
    addView(viewActivity);

    ViewGroup parent = (ViewGroup) scrollViewLeftMenu.getParent();
    parent.removeView(scrollViewLeftMenu);
    parent.removeView(scrollViewRightMenu);
  }
Пример #6
0
 @Override
 public HomeListAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
   View view =
       LayoutInflater.from(viewGroup.getContext())
           .inflate(R.layout.listview_homemenu, viewGroup, false);
   ViewHolder vh = new ViewHolder(view);
   return vh;
 }
Пример #7
0
  private Animation buildFlipHorizonalAnimation(final boolean forward) {
    final float centerY = container.getHeight() / 2.0f;
    final float centerX = 0;
    long duration = getFlipDurationFromPreference();

    Animation rotation =
        AnimationFactory.buildHorizontalFlipAnimation(forward, duration, centerX, centerY);

    rotation.setAnimationListener(flipAnimationListener);
    return rotation;
  }
Пример #8
0
 private View getFooterView() {
   if (mFooterView == null) {
     FrameLayout fl = new FrameLayout(getActivity());
     TextView tv = new TextView(getActivity());
     tv.setGravity(Gravity.CENTER);
     tv.setTextColor(0xFFaaaaaa);
     tv.setBackgroundColor(0xFFffffff);
     FrameLayout.LayoutParams params =
         new FrameLayout.LayoutParams(
             ViewGroup.LayoutParams.MATCH_PARENT, (int) CommonUtils.dpToPx(getActivity(), 50));
     fl.addView(tv, params);
     mFooterView = fl;
   }
   TextView tv = (TextView) mFooterView.getChildAt(0);
   tv.setText("共有" + SongManager.with(getActivity()).getSongSize() + "首歌");
   return mFooterView;
 }
Пример #9
0
  private void SetBackGroundforList() {
    // TODO Auto-generated method stub
    mDownView_parent_txt1 = new TextView(activity.getApplicationContext());
    RelativeLayout.LayoutParams lp1 =
        new RelativeLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mDownView_parent_txt1.setId(Integer.parseInt("111111"));
    mDownView_parent_txt1.setLayoutParams(lp1);
    mDownView_parent_txt1.setGravity(Gravity.CENTER_HORIZONTAL);
    mDownView_parent_txt1.setText(HalfText);
    mDownView_parent_txt1.setWidth(textwidth2);
    mDownView_parent_txt1.setPadding(0, textheight / 4, 0, 0);
    mDownView_parent_txt1.setHeight(textheight);
    mDownView_parent_txt1.setBackgroundColor(Color.parseColor(FullColor));
    mDownView_parent_txt1.setTextColor(Color.parseColor(TextColor));
    mDownView_parent_txt1.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    mDownView_parent.addView(mDownView_parent_txt1, 0);

    //         if(SwipeType==Double){
    //             mDownView_parent_txt2 = new TextView(activity.getApplicationContext());
    //             mDownView_parent_txt2.setId(222222);
    //             RelativeLayout.LayoutParams lp2 =new
    // RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT);
    //             lp2.addRule(RelativeLayout.LEFT_OF,mDownView_parent_txt1.getId());
    //             mDownView_parent_txt2.setLayoutParams(lp2);
    //             mDownView_parent_txt2.setGravity(Gravity.CENTER_HORIZONTAL);
    //             mDownView_parent_txt2.setText(FullText);
    //             mDownView_parent_txt2.setWidth(textwidth);
    //             mDownView_parent_txt2.setPadding(0, textheight/4, 0, 0);
    //             mDownView_parent_txt2.setHeight(textheight);
    //             mDownView_parent_txt2.setBackgroundColor(Color.parseColor(FullColor));
    //             mDownView_parent_txt2.setTextColor(Color.parseColor(TextColor));
    //             mDownView_parent_txt2.setCompoundDrawablesWithIntrinsicBounds(null ,
    // FullDrawable, null, null );
    //             mDownView_parent.addView(mDownView_parent_txt2, 1);
    //         }
  }
Пример #10
0
  private void showAnimation() {

    enlargedMode = false;
    renderNextPageIfNotRendered();
    // Log.d("ANI", "start animation");
    container.removeAllViews();
    if (current.isFirstPage()) {
      next.setVisibility(View.VISIBLE);
      currentPageIndex++;
      container.addView(current, pageViewLayoutParamsBack);
      container.addView(next, pageViewLayoutParamsFront);
      current.startAnimation(fadeInPageView);
    } else if (isWeiboMode()
        || next.isLastPage()
        || next.getWrapperViews().size() < 2
        || lastFlipDirection == ACTION_HORIZONTAL) {

      Animation rotation = buildFlipHorizonalAnimation(forward);
      if (forward) next.setVisibility(View.VISIBLE);
      else previous.setVisibility(View.VISIBLE);
      if (forward) {
        currentPageIndex++;

        container.addView(current, pageViewLayoutParamsBack);
        container.addView(next, pageViewLayoutParamsFront);
        current.startAnimation(rotation);
      } else {

        container.addView(current, pageViewLayoutParamsFront);
        container.addView(previous, pageViewLayoutParamsBack);
        previous.startAnimation(rotation);
      }
    } else {
      if (forward) {
        currentPageIndex++;
        container.addView(next, pageViewLayoutParamsFront);
      } else {
        container.addView(previous, pageViewLayoutParamsFront);
      }
      container.addView(current, pageViewLayoutParamsBack);

      if (forward) {
        currentUpper = current.getWrapperViews().get(0);
        currentBottom = current.getWrapperViews().get(1);
        nextUpper = next.getWrapperViews().get(0);
        nextBottom = next.getWrapperViews().get(1);
        final Animation flipToNext =
            buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, true);
        currentBottom.startAnimation(flipToNext);
      } else {
        currentUpper = current.getWrapperViews().get(0);
        currentBottom = current.getWrapperViews().get(1);
        nextUpper = previous.getWrapperViews().get(0);
        nextBottom = previous.getWrapperViews().get(1);

        final Animation flipToPrevious =
            buildFlipAnimation(currentUpper, currentBottom, nextUpper, nextBottom, false);
        currentUpper.startAnimation(flipToPrevious);
      }
    }
  }
Пример #11
0
 /**
  * Set up the activity;
  *
  * @param activity
  */
 public void attachToActivity(Activity activity) {
   initValue(activity);
   setShadowAdjustScaleXByOrientation();
   viewDecor.addView(this, 0);
 }
Пример #12
0
  private void performDismiss(final View dismissView, final int dismissPosition) {
    // Animate the dismissed list item to zero-height and fire the dismiss callback when
    // all dismissed list item animations have completed. This triggers layout on each animation
    // frame; in the future we may want to do something smarter and more performant.

    final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
    final int originalHeight = dismissView.getHeight();

    ((ViewGroup) dismissView)
        .getChildAt(1)
        .animate()
        .translationX(0)
        .alpha(1f)
        .setListener(
            new AnimatorListenerAdapter() {

              @Override
              public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                ((ViewGroup) dismissView).removeViewAt(0);
                Log.d(
                    "Selected view",
                    dismissView.getClass()
                        + "..."
                        + dismissView.getId()
                        + mDismissAnimationRefCount);
                ValueAnimator animator =
                    ValueAnimator.ofInt(originalHeight, 0).setDuration(mAnimationTime);
                animator.addListener(
                    new AnimatorListenerAdapter() {
                      @Override
                      public void onAnimationEnd(Animator animation) {
                        --mDismissAnimationRefCount;
                        if (mDismissAnimationRefCount == 0) {
                          // No active animations, process all pending dismisses.
                          // Sort by descending position
                          Collections.sort(mPendingDismisses);

                          int[] dismissPositions = new int[mPendingDismisses.size()];
                          for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
                            dismissPositions[i] = mPendingDismisses.get(i).position;
                            Log.d("Dismiss positions....", dismissPositions[i] + "");
                          }
                          tcallbacks.onDismiss(mListView, dismissPositions);
                          //                            ViewGroup.LayoutParams lp;
                          //                          for (PendingDismissData pendingDismiss :
                          // mPendingDismisses) {
                          //                              // Reset view presentation
                          //                              lp =
                          // pendingDismiss.view.getLayoutParams();
                          //                              lp.height = originalHeight;
                          //                              pendingDismiss.view.setLayoutParams(lp);
                          //                          }
                          mPendingDismisses.clear();
                        }
                      }
                    });

                animator.addUpdateListener(
                    new ValueAnimator.AnimatorUpdateListener() {
                      @Override
                      public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        lp.height = (Integer) valueAnimator.getAnimatedValue();
                        dismissView.setLayoutParams(lp);
                      }
                    });

                mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
                animator.start();
              }
            });
  }
Пример #13
0
  @SuppressLint("ResourceAsColor")
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
  @Override
  public boolean onTouch(final View view, MotionEvent event) {
    if (mViewWidth < 2) {
      mViewWidth = mListView.getWidth();
      smallWidth = mViewWidth / 7;
      textwidth2 = mViewWidth / 3;
      textwidth = textwidth2;
      //            原版
      //            largewidth	=	textwidth+textwidth2;
      //           自己修改
      largewidth = textwidth;
    }

    int tempwidth = 0;
    if (SwipeType == 1) tempwidth = smallWidth;
    else tempwidth = textwidth2 / 2;

    switch (event.getActionMasked()) {
      case MotionEvent.ACTION_DOWN:
        {
          if (mPaused) {
            return false;
          }
          Rect rect = new Rect();
          int childCount = mListView.getChildCount();
          int[] listViewCoords = new int[2];
          mListView.getLocationOnScreen(listViewCoords);
          int x = (int) event.getRawX() - listViewCoords[0];
          int y = (int) event.getRawY() - listViewCoords[1];
          ViewGroup child;
          for (int i = 0; i < childCount; i++) {
            child = (ViewGroup) mListView.getChildAt(i);
            child.getHitRect(rect);
            if (rect.contains(x, y)) {
              mDownView_parent = child;
              mDownView = (ViewGroup) child.findViewById(R.id.list_display_view_container);
              if (mDownView_parent.getChildCount() == 1) {
                textheight = mDownView_parent.getHeight();
                if (SwipeType == Dismiss) {
                  HalfColor = singleColor;
                  //                                HalfDrawable	=
                  //	activity.getResources().getDrawable(R.drawable.content_discard);
                }
                SetBackGroundforList();
              }

              if (old_mDownView != null && mDownView != old_mDownView) {
                ResetListItem(old_mDownView);
                old_mDownView = null;
                return false;
              }
              break;
            }
          }

          if (mDownView != null) {
            mDownX = event.getRawX();
            mDownY = event.getRawY();
            mDownPosition = mListView.getPositionForView(mDownView);
            mVelocityTracker = VelocityTracker.obtain();
            mVelocityTracker.addMovement(event);
          } else {
            mDownView = null;
          }

          // mSwipeDetected              =   false;
          temp_position = mListView.pointToPosition((int) event.getX(), (int) event.getY());
          view.onTouchEvent(event);
          return true;
        }

      case MotionEvent.ACTION_UP:
        {
          if (mVelocityTracker == null) {
            break;
          }
          float deltaX = event.getRawX() - mDownX;
          // 在OnItemClick事件中判断如果Deltax!=0则表示不是点击事件
          DeltaX = deltaX;
          mVelocityTracker.addMovement(event);
          mVelocityTracker.computeCurrentVelocity(1000); // 1000 by defaut but
          float velocityX = mVelocityTracker.getXVelocity(); // it was too much
          float absVelocityX = Math.abs(velocityX);
          float absVelocityY = Math.abs(mVelocityTracker.getYVelocity());
          boolean swipe = false;
          boolean swipeRight = false;

          if (Math.abs(deltaX) > tempwidth) {
            swipe = true;
            swipeRight = deltaX > 0;

          } else if (mMinFlingVelocity <= absVelocityX
              && absVelocityX <= mMaxFlingVelocity
              && absVelocityY < absVelocityX) {
            // dismiss only if flinging in the same direction as dragging
            swipe = (velocityX < 0) == (deltaX < 0);
            swipeRight = mVelocityTracker.getXVelocity() > 0;
          }
          if (deltaX < 0 && swipe) {
            mListView.setDrawSelectorOnTop(false);
            // && Math.abs(DeltaY)<30
            if (swipe && !swipeRight && deltaX <= -tempwidth && Math.abs(DeltaY) < 100) {
              FullSwipeTrigger();
            } else if (deltaX >= -textwidth && SwipeType == Double) {
              ResetListItem(mDownView);
            } else {
              ResetListItem(mDownView);
            }
          } else if (deltaX != 0) {
            ResetListItem(mDownView);
          }

          mVelocityTracker.recycle();
          mVelocityTracker = null;
          mDownX = 0;
          mDownView = null;
          mDownPosition = ListView.INVALID_POSITION;
          mSwiping = false;
          break;
        }

        // 根据手势滑动方向滑出滑入

      case MotionEvent.ACTION_MOVE:
        {
          float deltaX = event.getRawX() - mDownX;
          float deltaY = event.getRawY() - mDownY;
          DeltaY = deltaY;
          if (mVelocityTracker == null || mPaused || deltaX > 0) {
            break;
          }

          mVelocityTracker.addMovement(event);

          // && Math.abs(deltaY)<30
          if (Math.abs(deltaX) > (mSlop * 5) && Math.abs(deltaY) < 50) {
            mSwiping = true;
            mListView.requestDisallowInterceptTouchEvent(true);

            // Cancel ListView's touch (un-highlighting the item)
            MotionEvent cancelEvent = MotionEvent.obtain(event);
            cancelEvent.setAction(
                MotionEvent.ACTION_CANCEL
                    | (event.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
            mListView.onTouchEvent(cancelEvent);
            cancelEvent.recycle();
          } else if (Math.abs(deltaY) > 50) {
            mSwiping = false;
            //                     ResetListItem(mDownView);
          }
          System.out.println(
              "<<<<<<<<<" + deltaY + "<<<<<<" + deltaX + "<<<<" + mSwiping + "<<<<<" + mSlop * 10);
          if (mSwiping && deltaX < 0) {
            int width;
            //                     if(SwipeType==1){
            width = textwidth2;
            //                     }
            //                     else{
            //                         width	=	largewidth;
            //                     }

            if (-deltaX < width) {

              mDownView.setTranslationX(deltaX);
              return false;
            }
            return false;
          } else if (mSwiping) {
            ResetListItem(mDownView);
          }
          break;
        }
    }
    return false;
  }