Search in sources :

Example 1 with SwipeLayout

use of com.daimajia.swipe.SwipeLayout in project AndroidSwipeLayout by daimajia.

the class MyActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // SwipeLayout swipeLayout = (SwipeLayout)findViewById(R.id.godfather);
    // swipeLayout.setDragEdge(SwipeLayout.DragEdge.Bottom); // Set in XML
    // sample1
    sample1 = (SwipeLayout) findViewById(R.id.sample1);
    sample1.setShowMode(SwipeLayout.ShowMode.PullOut);
    View starBottView = sample1.findViewById(R.id.starbott);
    sample1.addDrag(SwipeLayout.DragEdge.Left, sample1.findViewById(R.id.bottom_wrapper));
    sample1.addDrag(SwipeLayout.DragEdge.Right, sample1.findViewById(R.id.bottom_wrapper_2));
    sample1.addDrag(SwipeLayout.DragEdge.Top, starBottView);
    sample1.addDrag(SwipeLayout.DragEdge.Bottom, starBottView);
    sample1.addRevealListener(R.id.delete, new SwipeLayout.OnRevealListener() {

        @Override
        public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
        }
    });
    sample1.getSurfaceView().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
            Log.d(MyActivity.class.getName(), "click on surface");
        }
    });
    sample1.getSurfaceView().setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(MyActivity.this, "longClick on surface", Toast.LENGTH_SHORT).show();
            Log.d(MyActivity.class.getName(), "longClick on surface");
            return true;
        }
    });
    sample1.findViewById(R.id.star2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
        }
    });
    sample1.findViewById(R.id.trash2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
        }
    });
    sample1.findViewById(R.id.magnifier2).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
        }
    });
    sample1.addRevealListener(R.id.starbott, new SwipeLayout.OnRevealListener() {

        @Override
        public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
            View star = child.findViewById(R.id.star);
            float d = child.getHeight() / 2 - star.getHeight() / 2;
            ViewHelper.setTranslationY(star, d * fraction);
            ViewHelper.setScaleX(star, fraction + 0.6f);
            ViewHelper.setScaleY(star, fraction + 0.6f);
        }
    });
    // sample2
    sample2 = (SwipeLayout) findViewById(R.id.sample2);
    sample2.setShowMode(SwipeLayout.ShowMode.LayDown);
    sample2.addDrag(SwipeLayout.DragEdge.Right, sample2.findViewWithTag("Bottom2"));
    // sample2.setShowMode(SwipeLayout.ShowMode.PullOut);
    sample2.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Star", Toast.LENGTH_SHORT).show();
        }
    });
    sample2.findViewById(R.id.trash).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Trash Bin", Toast.LENGTH_SHORT).show();
        }
    });
    sample2.findViewById(R.id.magnifier).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Magnifier", Toast.LENGTH_SHORT).show();
        }
    });
    sample2.findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Yo", Toast.LENGTH_SHORT).show();
        }
    });
    sample2.getSurfaceView().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
        }
    });
    // sample3
    sample3 = (SwipeLayout) findViewById(R.id.sample3);
    sample3.addDrag(SwipeLayout.DragEdge.Top, sample3.findViewWithTag("Bottom3"));
    sample3.addRevealListener(R.id.bottom_wrapper_child1, new SwipeLayout.OnRevealListener() {

        @Override
        public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
            View star = child.findViewById(R.id.star);
            float d = child.getHeight() / 2 - star.getHeight() / 2;
            ViewHelper.setTranslationY(star, d * fraction);
            ViewHelper.setScaleX(star, fraction + 0.6f);
            ViewHelper.setScaleY(star, fraction + 0.6f);
            int c = (Integer) evaluate(fraction, Color.parseColor("#dddddd"), Color.parseColor("#4C535B"));
            child.setBackgroundColor(c);
        }
    });
    sample3.findViewById(R.id.bottom_wrapper_child1).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Yo!", Toast.LENGTH_SHORT).show();
        }
    });
    sample3.getSurfaceView().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(MyActivity.this, "Click on surface", Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : SwipeLayout(com.daimajia.swipe.SwipeLayout) View(android.view.View)

Example 2 with SwipeLayout

use of com.daimajia.swipe.SwipeLayout in project AndroidSwipeLayout by daimajia.

the class RecyclerViewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final SimpleViewHolder viewHolder, final int position) {
    String item = mDataset.get(position);
    viewHolder.swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);
    viewHolder.swipeLayout.addSwipeListener(new SimpleSwipeListener() {

        @Override
        public void onOpen(SwipeLayout layout) {
            YoYo.with(Techniques.Tada).duration(500).delay(100).playOn(layout.findViewById(R.id.trash));
        }
    });
    viewHolder.swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {

        @Override
        public void onDoubleClick(SwipeLayout layout, boolean surface) {
            Toast.makeText(mContext, "DoubleClick", Toast.LENGTH_SHORT).show();
        }
    });
    viewHolder.buttonDelete.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mItemManger.removeShownLayouts(viewHolder.swipeLayout);
            mDataset.remove(position);
            notifyItemRemoved(position);
            notifyItemRangeChanged(position, mDataset.size());
            mItemManger.closeAllItems();
            Toast.makeText(view.getContext(), "Deleted " + viewHolder.textViewData.getText().toString() + "!", Toast.LENGTH_SHORT).show();
        }
    });
    viewHolder.textViewPos.setText((position + 1) + ".");
    viewHolder.textViewData.setText(item);
    mItemManger.bind(viewHolder.itemView, position);
}
Also used : SimpleSwipeListener(com.daimajia.swipe.SimpleSwipeListener) SwipeLayout(com.daimajia.swipe.SwipeLayout) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with SwipeLayout

use of com.daimajia.swipe.SwipeLayout in project AndroidSwipeLayout by daimajia.

the class NestedExample method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.complicate_layout);
    SwipeLayout swipeLayout = (SwipeLayout) findViewById(R.id.test_swipe_swipe);
    swipeLayout.setOnDoubleClickListener(new SwipeLayout.DoubleClickListener() {

        @Override
        public void onDoubleClick(SwipeLayout layout, boolean surface) {
            Toast.makeText(getApplicationContext(), "DoubleClick", Toast.LENGTH_SHORT).show();
        }
    });
    swipeLayout.findViewById(R.id.trash).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(), "Click", Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : SwipeLayout(com.daimajia.swipe.SwipeLayout) View(android.view.View)

Example 4 with SwipeLayout

use of com.daimajia.swipe.SwipeLayout in project AndroidSwipeLayout by daimajia.

the class SwipeItemMangerImpl method bind.

public void bind(View view, int position) {
    int resId = swipeAdapterInterface.getSwipeLayoutResourceId(position);
    SwipeLayout swipeLayout = (SwipeLayout) view.findViewById(resId);
    if (swipeLayout == null)
        throw new IllegalStateException("can not find SwipeLayout in target view");
    if (swipeLayout.getTag(resId) == null) {
        OnLayoutListener onLayoutListener = new OnLayoutListener(position);
        SwipeMemory swipeMemory = new SwipeMemory(position);
        swipeLayout.addSwipeListener(swipeMemory);
        swipeLayout.addOnLayoutListener(onLayoutListener);
        swipeLayout.setTag(resId, new ValueBox(position, swipeMemory, onLayoutListener));
        mShownLayouts.add(swipeLayout);
    } else {
        ValueBox valueBox = (ValueBox) swipeLayout.getTag(resId);
        valueBox.swipeMemory.setPosition(position);
        valueBox.onLayoutListener.setPosition(position);
        valueBox.position = position;
    }
}
Also used : SwipeLayout(com.daimajia.swipe.SwipeLayout)

Example 5 with SwipeLayout

use of com.daimajia.swipe.SwipeLayout in project TransitionPlayer by linfaxin.

the class ChromeHomeDemo method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.demo_chrome_home);
    swipeLayout = (SwipeLayout) findViewById(R.id.swipeLayout);
    swipeLayout.getDragEdgeMap().clear();
    swipeLayout.addDrag(SwipeLayout.DragEdge.Top, swipeLayout.getChildAt(0));
    swipeLayout.addRevealListener(R.id.placeHolder, new SwipeLayout.OnRevealListener() {

        @Override
        public void onReveal(View child, SwipeLayout.DragEdge edge, float fraction, int distance) {
            transitionPlayer.setCurrentFraction(fraction);
        }
    });
    swipeLayout.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            swipeLayout.getViewTreeObserver().removeOnPreDrawListener(this);
            ViewGroup mSceneRoot = (ViewGroup) findViewById(R.id.sceneRootView);
            Scene scene = Scene.getSceneForLayout(mSceneRoot, R.layout.chrome_home_head_state_expand, ChromeHomeDemo.this);
            transitionPlayer.setPlayControl(new ModifyAnimatorsPlayControl() {

                @Override
                protected Animator onModifyAnimator(Transition transition, ValueAnimator animator) {
                    if (!(animator instanceof ObjectAnimator))
                        return animator;
                    Object target = ((ObjectAnimator) animator).getTarget();
                    if (!(target instanceof View))
                        return animator;
                    View targetView = (View) target;
                    // input view
                    if (targetView.getId() == R.id.editText) {
                        if (transition instanceof ChangeBounds) {
                            AnimatorSet animatorSet = new AnimatorSet();
                            for (ValueAnimator subAnimator : AnimatorUtils.splitAnimatorByValues(animator)) {
                                animatorSet.playTogether(subAnimator);
                                // let input view fast animate to right edge
                                if (subAnimator instanceof ObjectAnimator && "right".equals(((ObjectAnimator) subAnimator).getPropertyName())) {
                                    MultiTimeInterpolator multi = new MultiTimeInterpolator();
                                    TimeInterpolator i = animator.getInterpolator();
                                    multi.addInterpolator(i, 6);
                                    LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
                                    multi.addInterpolator(end, 4);
                                    subAnimator.setInterpolator(multi);
                                }
                            }
                            return animatorSet;
                        } else if (transition instanceof ChangeTextColor) {
                            TimeInterpolator i = animator.getInterpolator();
                            LockEndTimeInterpolator end = new LockEndTimeInterpolator(i);
                            ReverseTimeInterpolator r = new ReverseTimeInterpolator(i);
                            animator.setInterpolator(new MultiTimeInterpolator(i, end, r));
                        }
                    }
                    // logo view
                    if (targetView.getId() == R.id.imageView && transition instanceof ChangeAlpha) {
                        MultiTimeInterpolator multi = new MultiTimeInterpolator();
                        TimeInterpolator i = new DecelerateInterpolator(1.6f);
                        TimeInterpolator start = new LockStartTimeInterpolator(i);
                        multi.addInterpolator(start, 4);
                        multi.addInterpolator(i, 6);
                        animator.setInterpolator(multi);
                    }
                    return animator;
                }
            });
            TransitionManager.go(scene, transitionPlayer);
            // after start transition, then init click.
            mSceneRoot.findViewById(R.id.editText).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    swipeLayout.close();
                }
            });
            return false;
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) AnimatorSet(android.animation.AnimatorSet) ChangeTextColor(com.linfaxin.transitionplayer.transitions.ChangeTextColor) ValueAnimator(android.animation.ValueAnimator) ChangeAlpha(com.linfaxin.transitionplayer.transitions.ChangeAlpha) LockStartTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockStartTimeInterpolator) LockEndTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockEndTimeInterpolator) SwipeLayout(com.daimajia.swipe.SwipeLayout) ViewTreeObserver(android.view.ViewTreeObserver) ViewGroup(android.view.ViewGroup) ObjectAnimator(android.animation.ObjectAnimator) ChangeBounds(android.transitions.everywhere.ChangeBounds) Scene(android.transitions.everywhere.Scene) View(android.view.View) TimeInterpolator(android.animation.TimeInterpolator) ReverseTimeInterpolator(com.linfaxin.transitionplayer.interpolators.ReverseTimeInterpolator) MultiTimeInterpolator(com.linfaxin.transitionplayer.interpolators.MultiTimeInterpolator) LockEndTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockEndTimeInterpolator) LockStartTimeInterpolator(com.linfaxin.transitionplayer.interpolators.LockStartTimeInterpolator) ReverseTimeInterpolator(com.linfaxin.transitionplayer.interpolators.ReverseTimeInterpolator) MultiTimeInterpolator(com.linfaxin.transitionplayer.interpolators.MultiTimeInterpolator) ModifyAnimatorsPlayControl(com.linfaxin.transitionplayer.control.ModifyAnimatorsPlayControl) Transition(android.transitions.everywhere.Transition)

Aggregations

SwipeLayout (com.daimajia.swipe.SwipeLayout)7 View (android.view.View)6 TextView (android.widget.TextView)3 RecyclerView (android.support.v7.widget.RecyclerView)2 SimpleSwipeListener (com.daimajia.swipe.SimpleSwipeListener)2 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 TimeInterpolator (android.animation.TimeInterpolator)1 ValueAnimator (android.animation.ValueAnimator)1 ProgressDialog (android.app.ProgressDialog)1 Intent (android.content.Intent)1 ChangeBounds (android.transitions.everywhere.ChangeBounds)1 Scene (android.transitions.everywhere.Scene)1 Transition (android.transitions.everywhere.Transition)1 ViewGroup (android.view.ViewGroup)1 ViewTreeObserver (android.view.ViewTreeObserver)1 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)1 ImageView (android.widget.ImageView)1 RadioGroup (android.widget.RadioGroup)1 Ride (br.ufrj.caronae.models.Ride)1