Example usage for android.widget ViewAnimator getDisplayedChild

List of usage examples for android.widget ViewAnimator getDisplayedChild

Introduction

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

Prototype

public int getDisplayedChild() 

Source Link

Document

Returns the index of the currently displayed child view.

Usage

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  w w .  j av a 2 s  . 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));
    }//from w  w  w  .  j  a  v a2 s .co  m
}

From source file:fm.libre.droid.LibreDroid.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem changeStation = menu.add(0, Menu.FIRST, 0, "Change Station").setIcon(R.drawable.back);
    MenuItem quit = menu.add(0, 2, 0, R.string.quit).setIcon(R.drawable.quit);
    changeStation.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            final ViewAnimator view = (ViewAnimator) findViewById(R.id.viewAnimator);
            if (view.getDisplayedChild() == 4) {
                LibreDroid.this.libreServiceConn.service.stop();
                LibreDroid.this.prevPage();
                LibreDroid.this.prevPage();
                LibreDroid.this.prevPage();
                return true;
            } else {
                return false;
            }/*from  ww w . j  a  v  a 2s. co  m*/
        }
    });

    quit.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        public boolean onMenuItemClick(MenuItem item) {
            LibreDroid.this.libreServiceConn.service.stop();
            LibreDroid.this.finish();
            return true;
        }
    });

    return super.onCreateOptionsMenu(menu);
}

From source file:fm.libre.droid.LibreDroid.java

public void nextPage() {
    final ViewAnimator view = (ViewAnimator) findViewById(R.id.viewAnimator);
    view.showNext();/* w  w  w.  j  ava2  s .  c  o m*/
    libreServiceConn.service.setCurrentPage(view.getDisplayedChild());
}

From source file:fm.libre.droid.LibreDroid.java

public void prevPage() {
    final ViewAnimator view = (ViewAnimator) findViewById(R.id.viewAnimator);
    view.showPrevious();/*  w w w.  ja  v  a2s  .  c  o m*/
    libreServiceConn.service.setCurrentPage(view.getDisplayedChild());
}

From source file:universe.constellation.orion.viewer.OrionViewerActivity.java

public void initCropScreen() {
    TableLayout cropTable = (TableLayout) findMyViewById(R.id.crop_borders);

    getSubscriptionManager().addDocListeners(new DocumentViewAdapter() {
        @Override/*from   www  . j a v a  2 s .  co  m*/
        public void documentOpened(Controller controller) {
            updateCrops();
        }
    });

    for (int i = 0; i < cropTable.getChildCount(); i++) {
        TableRow row = (TableRow) cropTable.getChildAt(i);
        row.findViewById(R.id.crop_plus);

        TextView valueView = (TextView) row.findViewById(R.id.crop_value);
        ImageButton plus = (ImageButton) row.findViewById(R.id.crop_plus);
        ImageButton minus = (ImageButton) row.findViewById(R.id.crop_minus);
        linkCropButtonsAndText(minus, plus, valueView, i);
    }

    //even cropping
    int index = 4;
    final TableLayout cropTable2 = (TableLayout) findMyViewById(R.id.crop_borders_even);
    for (int i = 0; i < cropTable2.getChildCount(); i++) {
        View child = cropTable2.getChildAt(i);
        if (child instanceof TableRow) {
            TableRow row = (TableRow) child;
            row.findViewById(R.id.crop_plus);
            TextView valueView = (TextView) row.findViewById(R.id.crop_value);
            ImageButton plus = (ImageButton) row.findViewById(R.id.crop_plus);
            ImageButton minus = (ImageButton) row.findViewById(R.id.crop_minus);
            linkCropButtonsAndText(minus, plus, valueView, index);
            index++;
            for (int j = 0; j < row.getChildCount(); j++) {
                View v = row.getChildAt(j);
                v.setEnabled(false);
            }
        }
    }

    final ImageButton switchEven = (ImageButton) findMyViewById(R.id.crop_even_button);
    if (switchEven != null) {
        final ViewAnimator cropAnim = (ViewAnimator) findMyViewById(R.id.crop_animator);
        switchEven.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                cropAnim.setDisplayedChild((cropAnim.getDisplayedChild() + 1) % 2);
                switchEven.setImageResource(
                        cropAnim.getDisplayedChild() == 0 ? R.drawable.next : R.drawable.prev);
            }
        });
    }

    final CheckBox checkBox = (CheckBox) findMyViewById(R.id.crop_even_flag);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            for (int i = 0; i < cropTable2.getChildCount(); i++) {
                View child = cropTable2.getChildAt(i);
                if (child instanceof TableRow) {
                    TableRow row = (TableRow) child;
                    for (int j = 0; j < row.getChildCount(); j++) {
                        View rowChild = row.getChildAt(j);
                        rowChild.setEnabled(isChecked);
                    }
                }
            }
        }
    });

    //        if (Device.Info.NOOK2) {
    //            TextView tv = (TextView) findMyViewById(R.id.navigation_title);
    //            int color = tv.getTextColors().getDefaultColor();
    //            checkBox.setTextColor(color);
    //        }

    ImageButton preview = (ImageButton) findMyViewById(R.id.crop_preview);
    preview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onApplyAction();
            controller.changeMargins(cropBorders[0], cropBorders[2], cropBorders[1], cropBorders[3],
                    checkBox.isChecked(), cropBorders[4], cropBorders[5]);
        }
    });

    ImageButton close = (ImageButton) findMyViewById(R.id.crop_close);
    close.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //main menu
            onAnimatorCancel();
            //reset if canceled
            updateCrops();
        }
    });
}