Example usage for android.widget LinearLayout post

List of usage examples for android.widget LinearLayout post

Introduction

In this page you can find the example usage for android.widget LinearLayout post.

Prototype

public boolean post(Runnable action) 

Source Link

Document

Causes the Runnable to be added to the message queue.

Usage

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

public void initZoomScreen() {
    //zoom screen

    final Spinner sp = (Spinner) findMyViewById(R.id.zoom_spinner);

    final EditText zoomText = (EditText) findMyViewById(R.id.zoom_picker_message);

    final SeekBar zoomSeek = (SeekBar) findMyViewById(R.id.zoom_picker_seeker);

    if (zoomSeek != null) {
        zoomSeek.setMax(300);/*from   ww w . j  av  a2s. c  o  m*/
        zoomSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (zoomInternal != 1) {
                    zoomText.setText("" + progress);
                    if (sp.getSelectedItemPosition() != 0) {
                        int oldInternal = zoomInternal;
                        zoomInternal = 2;
                        sp.setSelection(0);
                        zoomInternal = oldInternal;
                    }
                }
            }

            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
    }

    getSubscriptionManager().addDocListeners(new DocumentViewAdapter() {
        @Override
        public void documentOpened(Controller controller) {
            updateZoom();
        }
    });

    final ImageButton zplus = (ImageButton) findMyViewById(R.id.zoom_picker_plus);
    zplus.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            zoomSeek.incrementProgressBy(1);
        }
    });

    final ImageButton zminus = (ImageButton) findMyViewById(R.id.zoom_picker_minus);
    zminus.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (zoomSeek.getProgress() != 0) {
                zoomSeek.incrementProgressBy(-1);
            }
        }
    });

    ImageButton closeZoomPeeker = (ImageButton) findMyViewById(R.id.zoom_picker_close);
    closeZoomPeeker.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //main menu
            onAnimatorCancel();
            //updateZoom();
        }
    });

    ImageButton zoom_preview = (ImageButton) findMyViewById(R.id.zoom_preview);
    zoom_preview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onApplyAction();
            int index = sp.getSelectedItemPosition();
            controller.changeZoom(index == 0 ? (int) (Float.parseFloat(zoomText.getText().toString()) * 100)
                    : -1 * (index - 1));
            updateZoom();
        }
    });

    sp.setAdapter(new MyArrayAdapter());
    sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            boolean disable = position != 0;
            int oldZoomInternal = zoomInternal;
            if (zoomInternal != 2) {
                zoomInternal = 1;
                if (disable) {
                    zoomText.setText((String) parent.getAdapter().getItem(position));
                } else {
                    zoomText.setText("" + ((int) (controller.getCurrentPageZoom() * 10000)) / 100f);
                    zoomSeek.setProgress((int) (controller.getCurrentPageZoom() * 100));
                }
                zoomInternal = oldZoomInternal;
            }

            zminus.setVisibility(disable ? View.GONE : View.VISIBLE);
            zplus.setVisibility(disable ? View.GONE : View.VISIBLE);

            zoomText.setFocusable(!disable);
            zoomText.setFocusableInTouchMode(!disable);

            final LinearLayout parent1 = (LinearLayout) zoomText.getParent();

            parent1.post(new Runnable() {
                @Override
                public void run() {
                    parent1.requestLayout();
                }
            });
        }

        public void onNothingSelected(AdapterView<?> parent) {
            //To change body of implemented methods use File | Settings | File Templates.
        }
    });

    //by width
    sp.setSelection(1);

}