Search in sources :

Example 26 with LayoutAnimationController

use of android.view.animation.LayoutAnimationController in project instructure-android by instructure.

the class ClosedPollListFragment method configureViews.

@Override
public void configureViews(View rootView) {
    if (getArguments() != null) {
        ArrayList<Course> courseList = (ArrayList<Course>) getArguments().getSerializable(Constants.COURSES_LIST);
        if (courseList != null) {
            courseMap = createCourseMap(courseList);
        } else {
            courseMap = new HashMap<>();
        }
    } else {
        courseMap = new HashMap<>();
    }
    // set an animation for adding list items
    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.list_layout_controller);
    getListView().setLayoutAnimation(controller);
    pollMap = new HashMap<>();
}
Also used : ArrayList(java.util.ArrayList) LayoutAnimationController(android.view.animation.LayoutAnimationController) Course(com.instructure.canvasapi2.models.Course)

Example 27 with LayoutAnimationController

use of android.view.animation.LayoutAnimationController in project instructure-android by instructure.

the class PollSessionListFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    touchListener = new SwipeDismissListViewTouchListener(getListView(), new SwipeDismissListViewTouchListener.DismissCallbacks() {

        @Override
        public boolean canDismiss(int position) {
            return true;
        }

        @Override
        public void onDismiss(ListView listView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                // set the poll that we want to remove after the api call returns successfully
                PollSession pollSession = getItem(position);
                // remove the item from the list
                removeItem(pollSession);
                // delete the poll from canvas
                PollsManager.deletePollSession(poll.getId(), pollSession.getId(), responseCanvasCallback, true);
            }
        }
    });
    getListView().setOnTouchListener(touchListener);
    getListView().setOnScrollListener(touchListener.makeScrollListener());
    // set an animation for adding list items
    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.list_layout_controller);
    getListView().setLayoutAnimation(controller);
}
Also used : SwipeDismissListViewTouchListener(com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener) PollSession(com.instructure.canvasapi2.models.PollSession) ListView(android.widget.ListView) LayoutAnimationController(android.view.animation.LayoutAnimationController)

Example 28 with LayoutAnimationController

use of android.view.animation.LayoutAnimationController in project instructure-android by instructure.

the class QuestionListFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);
    // clear the list so we don't get duplicates
    pollList.clear();
    openSessions.clear();
    closedSessions.clear();
    setupClickListeners();
    touchListener = new SwipeDismissListViewTouchListener(expandableListView, new SwipeDismissListViewTouchListener.DismissCallbacks() {

        @Override
        public boolean canDismiss(int position) {
            return true;
        }

        @Override
        public void onDismiss(ListView listView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                // set the poll that we want to remove after the api call returns successfully
                pollToDelete = (Poll) expandableListView.getItemAtPosition(position);
                confirmDelete();
            }
        }
    });
    expandableListView.setOnTouchListener(touchListener);
    expandableListView.setOnScrollListener(touchListener.makeScrollListener());
    // set an animation for adding list items
    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.list_layout_controller);
    expandableListView.setLayoutAnimation(controller);
    ((BaseActivity) getActivity()).setActionBarTitle(getString(R.string.pollQuestions));
}
Also used : SwipeDismissListViewTouchListener(com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView) LayoutAnimationController(android.view.animation.LayoutAnimationController) BaseActivity(com.instructure.androidpolling.app.activities.BaseActivity)

Example 29 with LayoutAnimationController

use of android.view.animation.LayoutAnimationController in project android_frameworks_base by DirtyUnicorns.

the class ViewGroup method dispatchDraw.

@Override
protected void dispatchDraw(Canvas canvas) {
    boolean usingRenderNodeProperties = canvas.isRecordingFor(mRenderNode);
    final int childrenCount = mChildrenCount;
    final View[] children = mChildren;
    int flags = mGroupFlags;
    if ((flags & FLAG_RUN_ANIMATION) != 0 && canAnimate()) {
        final boolean buildCache = !isHardwareAccelerated();
        for (int i = 0; i < childrenCount; i++) {
            final View child = children[i];
            if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
                final LayoutParams params = child.getLayoutParams();
                attachLayoutAnimationParameters(child, params, i, childrenCount);
                bindLayoutAnimation(child);
            }
        }
        final LayoutAnimationController controller = mLayoutAnimationController;
        if (controller.willOverlap()) {
            mGroupFlags |= FLAG_OPTIMIZE_INVALIDATE;
        }
        controller.start();
        mGroupFlags &= ~FLAG_RUN_ANIMATION;
        mGroupFlags &= ~FLAG_ANIMATION_DONE;
        if (mAnimationListener != null) {
            mAnimationListener.onAnimationStart(controller.getAnimation());
        }
    }
    int clipSaveCount = 0;
    final boolean clipToPadding = (flags & CLIP_TO_PADDING_MASK) == CLIP_TO_PADDING_MASK;
    if (clipToPadding) {
        clipSaveCount = canvas.save();
        canvas.clipRect(mScrollX + mPaddingLeft, mScrollY + mPaddingTop, mScrollX + mRight - mLeft - mPaddingRight, mScrollY + mBottom - mTop - mPaddingBottom);
    }
    // We will draw our child's animation, let's reset the flag
    mPrivateFlags &= ~PFLAG_DRAW_ANIMATION;
    mGroupFlags &= ~FLAG_INVALIDATE_REQUIRED;
    boolean more = false;
    final long drawingTime = getDrawingTime();
    if (usingRenderNodeProperties)
        canvas.insertReorderBarrier();
    final int transientCount = mTransientIndices == null ? 0 : mTransientIndices.size();
    int transientIndex = transientCount != 0 ? 0 : -1;
    // Only use the preordered list if not HW accelerated, since the HW pipeline will do the
    // draw reordering internally
    final ArrayList<View> preorderedList = usingRenderNodeProperties ? null : buildOrderedChildList();
    final boolean customOrder = preorderedList == null && isChildrenDrawingOrderEnabled();
    for (int i = 0; i < childrenCount; i++) {
        while (transientIndex >= 0 && mTransientIndices.get(transientIndex) == i) {
            final View transientChild = mTransientViews.get(transientIndex);
            if ((transientChild.mViewFlags & VISIBILITY_MASK) == VISIBLE || transientChild.getAnimation() != null) {
                more |= drawChild(canvas, transientChild, drawingTime);
            }
            transientIndex++;
            if (transientIndex >= transientCount) {
                transientIndex = -1;
            }
        }
        final int childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder);
        final View child = getAndVerifyPreorderedView(preorderedList, children, childIndex);
        if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null) {
            more |= drawChild(canvas, child, drawingTime);
        }
    }
    while (transientIndex >= 0) {
        // there may be additional transient views after the normal views
        final View transientChild = mTransientViews.get(transientIndex);
        if ((transientChild.mViewFlags & VISIBILITY_MASK) == VISIBLE || transientChild.getAnimation() != null) {
            more |= drawChild(canvas, transientChild, drawingTime);
        }
        transientIndex++;
        if (transientIndex >= transientCount) {
            break;
        }
    }
    if (preorderedList != null)
        preorderedList.clear();
    // Draw any disappearing views that have animations
    if (mDisappearingChildren != null) {
        final ArrayList<View> disappearingChildren = mDisappearingChildren;
        final int disappearingCount = disappearingChildren.size() - 1;
        // Go backwards -- we may delete as animations finish
        for (int i = disappearingCount; i >= 0; i--) {
            final View child = disappearingChildren.get(i);
            more |= drawChild(canvas, child, drawingTime);
        }
    }
    if (usingRenderNodeProperties)
        canvas.insertInorderBarrier();
    if (debugDraw()) {
        onDebugDraw(canvas);
    }
    if (clipToPadding) {
        canvas.restoreToCount(clipSaveCount);
    }
    // mGroupFlags might have been updated by drawChild()
    flags = mGroupFlags;
    if ((flags & FLAG_INVALIDATE_REQUIRED) == FLAG_INVALIDATE_REQUIRED) {
        invalidate(true);
    }
    if ((flags & FLAG_ANIMATION_DONE) == 0 && (flags & FLAG_NOTIFY_ANIMATION_LISTENER) == 0 && mLayoutAnimationController.isDone() && !more) {
        // We want to erase the drawing cache and notify the listener after the
        // next frame is drawn because one extra invalidate() is caused by
        // drawChild() after the animation is over
        mGroupFlags |= FLAG_NOTIFY_ANIMATION_LISTENER;
        final Runnable end = new Runnable() {

            @Override
            public void run() {
                notifyAnimationListener();
            }
        };
        post(end);
    }
}
Also used : LayoutAnimationController(android.view.animation.LayoutAnimationController) Paint(android.graphics.Paint)

Example 30 with LayoutAnimationController

use of android.view.animation.LayoutAnimationController in project Manhua by ag2s20150909.

the class SearchActivity method showList.

private void showList(final SearchResult data) {
    SearchAdapter adapter = new SearchAdapter(this, data);
    lv.setLayoutAnimation(new LayoutAnimationController(AnimationUtils.loadAnimation(this, R.anim.list_animation), 0.5f));
    lv.setAdapter(adapter);
    Toast.makeText(getApplicationContext(), "共有" + (data.results.size()) + "条结果", Toast.LENGTH_LONG).show();
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4) {
            try {
                BookShelf.addBook(data.results.get(p3));
                Intent i = new Intent(getApplicationContext(), ListActivity.class);
                i.putExtra("url", data.results.get(p3).link);
                i.putExtra("book", data.results.get(p3));
                // Toast.makeText(getApplicationContext(), data.get(p3).get("link"), 1).show();
                startActivity(i);
            } catch (Exception e) {
                mHander.obtainMessage(0, e.getMessage()).sendToTarget();
            }
        }
    });
}
Also used : SearchAdapter(cn.liuyin.manhua.adapter.SearchAdapter) LayoutAnimationController(android.view.animation.LayoutAnimationController) AdapterView(android.widget.AdapterView) Intent(android.content.Intent) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

LayoutAnimationController (android.view.animation.LayoutAnimationController)35 ListView (android.widget.ListView)11 TranslateAnimation (android.view.animation.TranslateAnimation)9 Animation (android.view.animation.Animation)8 Paint (android.graphics.Paint)7 Cursor (android.database.Cursor)6 AlphaAnimation (android.view.animation.AlphaAnimation)6 AnimationSet (android.view.animation.AnimationSet)6 ListAdapter (android.widget.ListAdapter)6 SimpleCursorAdapter (android.widget.SimpleCursorAdapter)6 View (android.view.View)5 Intent (android.content.Intent)3 AdapterView (android.widget.AdapterView)3 ImageView (android.widget.ImageView)3 BaseActivity (com.instructure.androidpolling.app.activities.BaseActivity)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 ViewGroup (android.view.ViewGroup)2 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)2 SearchAdapter (cn.liuyin.manhua.adapter.SearchAdapter)2 SwipeDismissListViewTouchListener (com.instructure.androidpolling.app.util.SwipeDismissListViewTouchListener)2