Java Code Examples for android.view.animation.AnimationUtils.loadLayoutAnimation()

The following are Jave code examples for showing how to use loadLayoutAnimation() of the android.view.animation.AnimationUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AnimatedRecyclerView   File: AnimatedRecyclerView.java   Source Code and License Vote up 6 votes
@SuppressLint("Recycle")
private void init(Context context, @Nullable AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AnimatedRecyclerView, 0, 0);

    orientation = typedArray.getInt(R.styleable.AnimatedRecyclerView_layoutManagerOrientation, orientation);
    reverse = typedArray.getBoolean(R.styleable.AnimatedRecyclerView_layoutManagerReverse, reverse);
    animationDuration = typedArray.getInt(R.styleable.AnimatedRecyclerView_animationDuration, animationDuration);
    layoutManagerType = typedArray.getInt(R.styleable.AnimatedRecyclerView_layoutManagerType, layoutManagerType);
    columns = typedArray.getInt(R.styleable.AnimatedRecyclerView_gridLayoutManagerColumns, columns);
    animation = typedArray.getResourceId(R.styleable.AnimatedRecyclerView_layoutAnimation, -1);

    if (animationController == null)
        animationController = animation != -1
                ? AnimationUtils.loadLayoutAnimation(getContext(), animation)
                : AnimationUtils.loadLayoutAnimation(getContext(), R.anim.layout_animation_from_bottom);

    animationController.getAnimation().setDuration(animationDuration);
    setLayoutAnimation(animationController);

    if (layoutManagerType == LayoutManagerType.LINEAR)
        setLayoutManager(new LinearLayoutManager(context, orientation, reverse));
    else if (layoutManagerType == LayoutManagerType.GRID)
        setLayoutManager(new GridLayoutManager(context, columns, orientation, reverse));
}
 
Example 2
Project: Synapse   File: MainActivity.java   Source Code and License Vote up 6 votes
private void solveData() {
    mButler.clear();

    final boolean ready = isDataSetReady();

    if (ready) {
        final LayoutAnimationController controller =
                AnimationUtils.loadLayoutAnimation(this, R.anim.layout_animation_from_bottom);

        mRecyclerView.setLayoutAnimation(controller);
        mRecyclerView.scheduleLayoutAnimation();

        dataSetReady();
    } else {
        dataSetUnready();
    }
}
 
Example 3
Project: buildAPKsSamples   File: Home.java   Source Code and License Vote up 6 votes
/**
     * Hides all of the applications by playing an animation on the grid.
     */
    private void hideApplications() {
        if (mBlockAnimation) {
            return;
        }
        mBlockAnimation = true;

        mShowApplicationsCheck.toggle();

        if (mHideLayoutAnimation == null) {
            mHideLayoutAnimation = AnimationUtils.loadLayoutAnimation(
                    this, R.anim.hide_applications);
        }

        mGridExit.setAnimationListener(new HideGrid());
        mGrid.startAnimation(mGridExit);
        mGrid.setVisibility(View.INVISIBLE);
        mShowApplications.requestFocus();

        // This enables a layout animation; if you uncomment this code, you need to
        // comment the line mGrid.startAnimation() above
//        mGrid.setLayoutAnimationListener(new HideGrid());
//        mGrid.setLayoutAnimation(mHideLayoutAnimation);
//        mGrid.startLayoutAnimation();
    }
 
Example 4
Project: phonk   File: ProjectListFragment.java   Source Code and License Vote up 6 votes
public void loadFolder(String folder) {
    clear();

    mProjectFolder = folder;

    mListProjects = PhonkScriptHelper.listProjects(mProjectFolder, mOrderByName);
    mProjectAdapter.setArray(mListProjects);
    mGrid.setAdapter(mProjectAdapter);
    // mGrid.clearAnimation();
    // mGrid.startAnimation(mAnim);

    notifyAddedProject();

    final Context context = mGrid.getContext();
    final LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(context, R.anim.fav_grid_anim);

    mGrid.setLayoutAnimation(controller);
    mGrid.getAdapter().notifyDataSetChanged();
    mGrid.scheduleLayoutAnimation();

    MLog.d(TAG, "loading " + mProjectFolder);
}
 
Example 5
Project: CP-Tester   File: MainActivity.java   Source Code and License Vote up 5 votes
private void runLayoutAnimation() {
    final LayoutAnimationController controller =
            AnimationUtils.loadLayoutAnimation(getApplicationContext(), R.anim.layout_animation_fall_down);
    mRecyclerView.setLayoutAnimation(controller);
    mRecyclerView.getAdapter().notifyDataSetChanged();
    mRecyclerView.scheduleLayoutAnimation();
}
 
Example 6
Project: MVP-Android   File: RecyclerViewUtils.java   Source Code and License Vote up 5 votes
public static void runLayoutAnimation(final RecyclerView recyclerView) {
    final Context context = recyclerView.getContext();
    final LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(context, R.anim.layout_animation_fall_up);

    recyclerView.setLayoutAnimation(controller);
    recyclerView.getAdapter().notifyDataSetChanged();
    recyclerView.scheduleLayoutAnimation();
}
 
Example 7
Project: MVP-Android   File: RecyclerViewUtils.java   Source Code and License Vote up 5 votes
public static void runLayoutAnimation(final RecyclerView recyclerView, @AnimRes int res) {
    final Context context = recyclerView.getContext();
    final LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(context, res);

    recyclerView.setLayoutAnimation(controller);
    recyclerView.getAdapter().notifyDataSetChanged();
    recyclerView.scheduleLayoutAnimation();
}
 
Example 8
Project: buildAPKsSamples   File: Home.java   Source Code and License Vote up 5 votes
/**
     * Shows all of the applications by playing an animation on the grid.
     */
    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);
    }
 
Example 9
Project: Charities   File: CharitiesResultsActivity.java   Source Code and License Vote up 5 votes
private void runLayoutAnimation(final RecyclerView recyclerView) {
    final Context context = recyclerView.getContext();
    final LayoutAnimationController controller =
            AnimationUtils.loadLayoutAnimation(context, R.anim.rv_layout_animation);

    recyclerView.setLayoutAnimation(controller);
    recyclerView.getAdapter().notifyDataSetChanged();
    recyclerView.scheduleLayoutAnimation();
}
 
Example 10
Project: INFOotball   File: BaseFragment.java   Source Code and License Vote up 4 votes
private final void runLayoutAnimation(int animation){
    final LayoutAnimationController controller = AnimationUtils.loadLayoutAnimation(getActivity(),animation);
    recyclerViewContent.setLayoutAnimation(controller);
    recyclerViewContent.scheduleLayoutAnimation();
}
 
Example 11
Project: file.io-app   File: UploadHistoryActivity.java   Source Code and License Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_upload_history);

    ButterKnife.bind(this);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle(getString(R.string.upload_history_title));
        actionBar.setDisplayHomeAsUpEnabled(true);
    }


    final RecyclerView recyclerView = findViewById(R.id.list);
    final UploadHistoryListAdapter uploadHistoryListAdapter = new UploadHistoryListAdapter(this);

    uploadItemViewModel = ViewModelProviders.of(this).get(UploadItemViewModel.class);
    uploadItemViewModel
            .getUploadHistoryList()
            .observe(this, new Observer<List<UploadItem>>() {
                @Override
                public void onChanged(@Nullable List<UploadItem> uploadItems) {
                    if ((uploadItems == null) || uploadItems.isEmpty()) {
                        noUploadsView.setVisibility(View.VISIBLE);
                        recyclerView.setVisibility(View.INVISIBLE);
                        MaterialIn.animate(noUploadsView);
                    } else {
                        noUploadsView.setVisibility(View.INVISIBLE);
                        recyclerView.setVisibility(View.VISIBLE);
                        uploadHistoryListAdapter.setUploadItemList(uploadItems);
                    }
                }
            });

    recyclerView.setAdapter(uploadHistoryListAdapter);

    uploadHistoryListAdapter.setOnUploadItemLongClickListener(this);

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);
    LayoutAnimationController layoutAnimationController = AnimationUtils.loadLayoutAnimation(this, R.anim.layout_anim_fall_down);
    recyclerView.setLayoutAnimation(layoutAnimationController);

}