Example usage for android.widget ViewAnimator setDisplayedChild

List of usage examples for android.widget ViewAnimator setDisplayedChild

Introduction

In this page you can find the example usage for android.widget ViewAnimator setDisplayedChild.

Prototype

@android.view.RemotableViewMethod
public void setDisplayedChild(int whichChild) 

Source Link

Document

Sets which child view will be displayed.

Usage

From source file:com.example.kent_zheng.sdk_adaptertransition.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_toggle_log:
        mLogShown = !mLogShown;//  ww w.  ja  v a2s . c o m
        ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
        if (mLogShown) {
            output.setDisplayedChild(1); // fragment
        } else {
            output.setDisplayedChild(0); //  textView
        }
        supportInvalidateOptionsMenu();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.daiki.arduino.mcheck.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
    case R.id.menu_toggle_log:
        mLogShown = !mLogShown;/*from   w ww  .  jav a2  s.c  o m*/
        ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
        if (mLogShown) {
            output.setDisplayedChild(1);
        } else {
            output.setDisplayedChild(0);
        }
        supportInvalidateOptionsMenu();
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:org.amahi.anywhere.util.ViewDirector.java

public void show(int viewId) {
    ViewAnimator animator = (ViewAnimator) findView(animatorId);
    View view = findView(viewId);

    if (animator.getDisplayedChild() != animator.indexOfChild(view)) {
        animator.setDisplayedChild(animator.indexOfChild(view));
    }//from   w  ww. j  av  a 2s  . c  o  m
}

From source file:org.hawkular.client.android.util.ViewDirector.java

@UiThread
public void show(@IdRes int viewId) {
    ViewAnimator animator = (ViewAnimator) sceneView.findViewById(animatorId);
    View view = sceneView.findViewById(viewId);

    if (animator.getDisplayedChild() != animator.indexOfChild(view)) {
        animator.setDisplayedChild(animator.indexOfChild(view));
    }/*w  w  w.  j a va 2 s  .  com*/
}

From source file:st.ghostca.ghostcast.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_toggle_log:
        mLogShown = !mLogShown;/*from   w ww  .  j ava  2 s .  c o  m*/
        ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
        if (mLogShown) {
            output.setDisplayedChild(1);

            View backgroundMap = findViewById(R.id.background_map);
            backgroundMap.setVisibility(View.VISIBLE);
            backgroundMap.setAlpha(1);
            View core = findViewById(R.id.core_fragment);
            slideDown(core);
        } else {
            output.setDisplayedChild(0);

            View backgroundMap = findViewById(R.id.background_map);
            backgroundMap.setVisibility(View.GONE);
            backgroundMap.setAlpha(0);

            View core = findViewById(R.id.core_fragment);
            slideUp(core);
        }
        supportInvalidateOptionsMenu();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.example.android.bluetoothchat.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_toggle_log:
        mLogShown = !mLogShown;//  w w w  .j a  v  a 2 s.c o m
        ViewAnimator output = (ViewAnimator) findViewById(R.id.sample_output);
        if (mLogShown) {
            output.setDisplayedChild(1);
        } else {
            output.setDisplayedChild(0);
        }
        supportInvalidateOptionsMenu();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:org.libreoffice.impressremote.fragment.ComputerConnectionFragment.java

private void setCurrentView(int aViewId) {
    ViewAnimator aViewAnimator = getViewAnimator();
    View aView = getView().findViewById(aViewId);

    aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aView));
}

From source file:org.libreoffice.impressremote.fragment.ComputersFragment.java

private void setCurrentView(int aViewId) {
    ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator);
    View aView = getView().findViewById(aViewId);

    if (aViewId == aViewAnimator.getCurrentView().getId()) {
        return;//from   w  w w .j  a  va 2  s.  c  om
    }

    aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aView));
}

From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java

private void onDataSetChanged() {
    View emptyView = findViewById(android.R.id.empty);
    TextView emptyDescription = (TextView) findViewById(R.id.empty_description);
    if (mChosenUris != null && mChosenUris.getCount() > 0) {
        emptyView.setVisibility(View.GONE);
        // We have at least one image, so consider the Gallery source properly setup
        setResult(RESULT_OK);/*from ww  w  .java2  s  .  co  m*/
    } else {
        // No chosen images, show the empty View
        emptyView.setVisibility(View.VISIBLE);
        ViewAnimator animator = (ViewAnimator) findViewById(R.id.empty_animator);
        if (ContextCompat.checkSelfPermission(this,
                Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            // Permission is granted, we can show the random camera photos image
            animator.setDisplayedChild(0);
            emptyDescription.setText(R.string.gallery_empty);
            setResult(RESULT_OK);
        } else {
            // We have no images until they enable the permission
            setResult(RESULT_CANCELED);
            if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                    Manifest.permission.READ_EXTERNAL_STORAGE)) {
                // We should show rationale on why they should enable the storage permission and
                // random camera photos
                animator.setDisplayedChild(1);
                emptyDescription.setText(R.string.gallery_permission_rationale);
            } else {
                // The user has permanently denied the storage permission. Give them a link to app settings
                animator.setDisplayedChild(2);
                emptyDescription.setText(R.string.gallery_denied_explanation);
            }
        }
    }
}

From source file:com.doplgangr.secrecy.views.FilesListFragment.java

void switchView(final View frame, final int showView) {
    getActivity().runOnUiThread(new Runnable() {
        @Override/*from www  .  j  a  v a  2s. c o  m*/
        public void run() {
            if (frame == null) {
                return;
            }
            FilesListAdapter.ViewHolder holder = (FilesListAdapter.ViewHolder) frame.getTag();
            ViewAnimator viewAnimator = holder.animator;
            viewAnimator.setInAnimation(context, R.anim.slide_down);
            int viewIndex = 0;
            switch (showView) {
            case R.id.dataLayout:
                viewIndex = 0;
                break;
            case R.id.DecryptLayout:
                viewIndex = 1;
                break;
            }
            viewAnimator.setDisplayedChild(viewIndex);
            viewAnimator.setInAnimation(null);
            holder.page = viewIndex;
        }
    });
}