Example usage for android.view.animation AnimationUtils loadLayoutAnimation

List of usage examples for android.view.animation AnimationUtils loadLayoutAnimation

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils loadLayoutAnimation.

Prototype

public static LayoutAnimationController loadLayoutAnimation(Context context, @AnimRes int id)
        throws NotFoundException 

Source Link

Document

Loads a LayoutAnimationController object from a resource

Usage

From source file:Main.java

/** load a layout animation sequence from xml */
public static void setLayoutAnimation2(ViewGroup panel, Context ctx) {

    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(ctx, R.anim.slide_in_left);

    panel.setLayoutAnimation(controller);

}

From source file:com.google.training.cpd200.conference.android.ConferenceListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    getListView().setFastScrollEnabled(true);
    LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(getActivity(),
            R.anim.list_layout_controller);
    getListView().setLayoutAnimation(controller);
    mAdapter = new ConferenceDataAdapter(getActivity());
    setEmptyText(getString(R.string.no_conferences));
    setListAdapter(mAdapter);//from ww w.  ja  v  a2s .  c  o m
    setListShown(false);
}

From source file:me.zchang.onchart.ui.LessonListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_lesson_list, container, false);
    courseList = (RecyclerView) rootView.findViewById(R.id.rv_lessons);
    adapter.setCourses(courses);/*from   ww  w.j av a 2s. c  o  m*/
    courseList.setAdapter(adapter);
    if (slideAnimFlag) {
        courseList.setLayoutAnimation(
                AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.main_recycler_view_layout));
    }
    return rootView;
}

From source file:com.schedule.MessagesFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);

    int mTargetIndex = 1;

    if (getArguments() != null) {
        mTargetIndex = getArguments().getInt(TARGET_INDEX, 0);
    }/*from  w  w w. j a  v  a2  s  .co  m*/

    String[] selectionArgs = new String[] { String.valueOf(mTargetIndex) };

    mCursor = getActivity().managedQuery(MessageEntry.MESSAGE_TABLE_CONTENTURI, projection, selection,
            selectionArgs, null);

    String[] from = new String[] { MessageEntry.COLUMN_CONTENT };
    int[] to = new int[] { R.id.tv_content };

    mAdapter = new SimpleCursorAdapter(getActivity(), R.layout.message_list_item, mCursor, from, to);
    setListAdapter(mAdapter);
    getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    getListView().setLayoutAnimation(
            AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_bottom_to_top_slide));
}

From source file:org.jraf.android.hellomundo.app.pickwebcam.PickWebcamListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View res = super.onCreateView(inflater, container, savedInstanceState);

    // Add 'random' item
    ListView listView = (ListView) res.findViewById(android.R.id.list);
    setListAdapter(mAdapter);//www . j a v  a 2 s.c o  m
    mAdapter.setListView(listView);
    listView.addHeaderView(getHeaderView(listView), null, true);

    // Disable dividers since they are handled manually in cell layouts
    listView.setDividerHeight(0);

    // Disable this optimization because this cause problems on dividers in hdpi
    listView.setScrollingCacheEnabled(false);

    // Layout animation
    listView.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.listview_layout));
    return res;
}

From source file:com.schedule.MessagesFragment.java

/**
  * Displays a particular article./*from   w ww.ja va 2s  .  c  o  m*/
  *
  * @param article the article to display
  */
public void displayMessage(long targetId) {

    String[] selectionArgs = new String[] { String.valueOf(targetId) };
    //     Toast.makeText(getActivity(), "id:"+targetId+",selectArgs:"+selectionArgs.toString(), 1).show();
    mCursor = getActivity().managedQuery(MessageEntry.MESSAGE_TABLE_CONTENTURI, projection, selection,
            selectionArgs, null);

    mAdapter.changeCursor(mCursor);

    getListView().setLayoutAnimation(
            AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_bottom_to_top_slide));
    // mAdapter.notifyDataSetChanged();
}

From source file:com.schedule.TargetsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState);

    //initData();
    String[] from = { TargetEntry.COLUMN_NAME };

    int[] to = { android.R.id.text1 };

    mListAdapter = new SimpleCursorAdapter(getActivity(), R.layout.headline_item, null, from, to);
    getLoaderManager().initLoader(TARGET_LOADER, null, this);

    getListView().setLayoutAnimation(/* w w w.  j a  v  a2 s  .c  o  m*/
            AnimationUtils.loadLayoutAnimation(getActivity(), R.anim.layout_bottom_to_top_slide));
    //      
    //      String[]mStrings=new String[]{"a","b","c","d"};
    //      
    //       getListView().setAdapter(new ArrayAdapter<String>(this.getActivity(),
    //                   android.R.layout.simple_list_item_activated_1, mStrings));
    //       
    getListView().setTextFilterEnabled(true);

    // Tell the list view to show one checked/activated item at a time.
    //       getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    // Start with first item activated.
    // Make the newly clicked item the currently selected one.
    getListView().setItemChecked(0, true);
}

From source file:com.koushikdutta.superuser.FragmentMain.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    context = getActivity();//from www . ja v  a 2s. c o m

    pref = PreferenceManager.getDefaultSharedPreferences(context);

    callback = (MainCallback) getActivity();

    LocalBroadcastManager.getInstance(context).registerReceiver(receiver,
            new IntentFilter(Common.INTENT_FILTER_MAIN));

    gridMode = pref.getBoolean("grid_mode", true);

    coordinatorLayout = (CoordinatorLayout) getActivity().findViewById(R.id.main_content);

    //tabLayout = (TabLayout) getActivity().findViewById(R.id.tabs);

    //viewPager = (ViewPager) getActivity().findViewById(R.id.container);

    int span = 0;

    if (gridMode) {
        layoutManager = new RecyclerViewSwipeable.LayoutManagerSwipeable(context, 1);

        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
            span = pref.getInt("grid_size_port", 3);
            layoutManager.setSpanCount(span);

        } else if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            span = pref.getInt("grid_size_land", 4);
            layoutManager.setSpanCount(span);
        }

        Drawable divider = ContextCompat.getDrawable(context, R.drawable.divider_grid);
        divider.setColorFilter(new PorterDuffColorFilter(ATHUtil.resolveColor(context, R.attr.dividerGrid),
                PorterDuff.Mode.SRC_ATOP));

        recycler.setLayoutManager(layoutManager);

        recycler.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(context, R.anim.grid_layout_animation));

        recycler.addItemDecoration(new GridDividerItemDecoration(divider, divider, span));

        recycler.addItemDecoration(new GridTopOffsetItemDecoration(Util.toPx(context, 5), span));

    } else {
        recycler.setLayoutManager(new LinearLayoutManager(context));

        recycler.addItemDecoration(new StartOffsetItemDecoration(Util.toPx(context, 10)));
    }

    //recycler.setListener(clickListener);
    //recycler.setViewPager(viewPager);
    //recycler.setFragment(this);

    setData();
}

From source file:com.android.contacts.list.MultiSelectContactsListFragment.java

protected void setLayoutAnimation(final ViewGroup view, int animationId) {
    if (view == null) {
        return;/*  w  w w . j a  v  a 2s  . c o m*/
    }
    view.setLayoutAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.setLayoutAnimation(null);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    view.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(getActivity(), animationId));
}

From source file:com.example.android.home.Home.java

/**
 * Shows all of the applications by playing an animation on the grid.
 *///from  www .j a va 2 s.  co m
private void showApplications(boolean animate) {
    if (mBlockAnimation) {
        return;
    }
    mBlockAnimation = true;

    mShowApplicationsCheck.toggle();

    if (mShowLayoutAnimation == null) {
        mShowLayoutAnimation = AnimationUtils.loadLayoutAnimation(this, R.anim.show_applications);
    }

    // This enables a layout animation; if you uncomment this code, you need to
    // comment the line mGrid.startAnimation() below
    //        mGrid.setLayoutAnimationListener(new ShowGrid());
    //        mGrid.setLayoutAnimation(mShowLayoutAnimation);
    //        mGrid.startLayoutAnimation();

    if (animate) {
        mGridEntry.setAnimationListener(new ShowGrid());
        mGrid.startAnimation(mGridEntry);
    }

    mGrid.setVisibility(View.VISIBLE);

    if (!animate) {
        mBlockAnimation = false;
    }

    // ViewDebug.startHierarchyTracing("Home", mGrid);
}