Example usage for android.view View isShown

List of usage examples for android.view View isShown

Introduction

In this page you can find the example usage for android.view View isShown.

Prototype

public boolean isShown() 

Source Link

Document

Returns the visibility of this view and all of its ancestors

Usage

From source file:cw.kop.autobackground.sources.SourceListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {

    View expandedView = view.findViewById(R.id.source_expand_container);
    if (expandedView.isShown()) {
        expandedView.setVisibility(View.GONE);
    } else {//from w  ww  . j  a va  2  s  .  c om
        expandedView.setVisibility(View.VISIBLE);
        sourceList.smoothScrollToPositionFromTop(position, (int) (sourceList.getHeight() / 2
                - view.getHeight() / 2 - addButtonBackground.getHeight() * 1.5), SCROLL_ANIMATION_TIME);
    }

}

From source file:eu.trentorise.smartcampus.jp.MonitorJourneyFragment.java

@Override
protected void setUpMainOperation() {
    // if (params.getClientId() == null) {
    // getView().findViewById(R.id.recurr_delete).setVisibility(View.GONE);
    // } else {/* w  ww. j av a2  s .  c o  m*/
    // ((Button)
    // getView().findViewById(R.id.recurr_delete)).setOnClickListener(new
    // View.OnClickListener() {
    //
    // @Override
    // public void onClick(View v) {
    // SCAsyncTask<String, Void, Void> task = new SCAsyncTask<String, Void,
    // Void>(getSherlockActivity(),
    // new DeleteMyRecurItineraryProcessor(getSherlockActivity()));
    // task.execute(params.getName(), params.getClientId());
    // }
    // });
    // }
    Button nextButton = (Button) getView().findViewById(R.id.recurr_next);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // user preferences
            View userPrefsLayout = (View) getView().findViewById(R.id.plannew_userprefs);
            alwaysCheckbox = (CheckBox) getView().findViewById(R.id.always_checkbox);
            if (userPrefsLayout.isShown()) {
                TableLayout tTypesTableLayout = (TableLayout) userPrefsLayout
                        .findViewById(R.id.transporttypes_table);
                RadioGroup rTypesRadioGroup = (RadioGroup) userPrefsLayout
                        .findViewById(R.id.routetypes_radioGroup);
                userPrefsHolder = PrefsHelper.userPrefsViews2Holder(tTypesTableLayout, rTypesRadioGroup,
                        userPrefs);
            } else {
                userPrefsHolder = PrefsHelper.sharedPreferences2Holder(userPrefs);
            }

            // EditText name = (EditText) getView().findViewById(R.id.name);
            // if (name.getText() == null ||
            // name.getText().toString().length() == 0) {
            // Toast.makeText(getActivity(), R.string.name_field_empty,
            // Toast.LENGTH_SHORT).show();
            // return;
            // }
            // params.setName(name.getText().toString().trim());
            // params.setMonitor(((CheckBox)
            // getView().findViewById(R.id.recur_monitor)).isChecked());

            RecurrentJourneyParameters rj = params.getData().getParameters();
            if (fromPosition == null) {
                // Toast.makeText(getActivity(), R.string.from_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), fromEditText,
                        getResources().getString(R.string.from_field_empty));
                return;
            }
            if (toPosition == null) {
                // Toast.makeText(getActivity(), R.string.to_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), toEditText,
                        getResources().getString(R.string.to_field_empty));
                return;
            }

            rj.setFrom(fromPosition);
            rj.setTo(toPosition);

            Date fromDateD;
            Date fromTimeD;
            Date toDateD;
            Date toTimeD;

            CharSequence timeString = fromDate.getText();
            if (timeString == null) {
                // Toast.makeText(getActivity(),
                // R.string.from_date_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), fromDate,
                        getResources().getString(R.string.from_date_field_empty));
                return;
            } else {
                try {
                    fromDateD = Config.FORMAT_DATE_UI.parse(timeString.toString());
                    rj.setFromDate(fromDateD.getTime());
                } catch (ParseException e) {
                    // Toast.makeText(getActivity(),
                    // R.string.from_date_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), fromDate,
                            getResources().getString(R.string.from_date_field_empty));
                    return;
                }
            }

            timeString = fromTime.getText();
            if (timeString == null) {
                // Toast.makeText(getActivity(),
                // R.string.from_time_field_empty,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), fromTime,
                        getResources().getString(R.string.from_time_field_empty));
                return;
            } else {
                try {
                    fromTimeD = Config.FORMAT_TIME_UI.parse(timeString.toString());
                    rj.setTime(Config.FORMAT_TIME_SMARTPLANNER.format(fromTimeD));
                } catch (ParseException e) {
                    // Toast.makeText(getActivity(),
                    // R.string.from_time_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), fromTime,
                            getResources().getString(R.string.from_time_field_empty));
                    return;
                }
            }

            // if
            // (!eu.trentorise.smartcampus.jp.helper.Utils.validFromDateTime(fromDateD,
            // fromTimeD)) {
            // Toast.makeText(getActivity(), R.string.datetime_before_now,
            // Toast.LENGTH_SHORT).show();
            // return;
            // }
            if (alwaysCheckbox.isChecked()) {
                rj.setToDate(Config.ALWAYS_DATE);
            }

            timeString = toDate.getText();
            if (!alwaysCheckbox.isChecked())

                if (timeString == null) {
                    // Toast.makeText(getActivity(),
                    // R.string.to_date_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), toDate,
                            getResources().getString(R.string.to_date_field_empty));
                    return;
                } else {
                    try {
                        toDateD = Config.FORMAT_DATE_UI.parse(timeString.toString());
                        rj.setToDate(toDateD.getTime());
                        if (rj.getFromDate() == rj.getToDate())
                            rj.setToDate(rj.getToDate() + (24 * 60 * 60 * 1000));
                        if ((rj.getToDate() < rj.getFromDate()) && !alwaysCheckbox.isChecked()) {
                            // Toast.makeText(getActivity(),
                            // R.string.to_date_before_from_date,
                            // Toast.LENGTH_SHORT).show();
                            ValidatorHelper.highlight(getSherlockActivity(), toDate,
                                    getResources().getString(R.string.to_date_before_from_date));
                            return;
                        }

                    } catch (ParseException e) {
                        // Toast.makeText(getActivity(),
                        // R.string.to_date_field_empty,
                        // Toast.LENGTH_SHORT).show();
                        ValidatorHelper.highlight(getSherlockActivity(), toDate,
                                getResources().getString(R.string.to_date_field_empty));
                        return;
                    }
                }
            else
                toDateD = new Date(Config.ALWAYS_DATE);

            timeString = toTime.getText();
            if (timeString == null) {
                // Toast.makeText(getActivity(),
                // R.string.to_time_field_empty, Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), toTime,
                        getResources().getString(R.string.to_time_field_empty));
                return;
            } else {
                try {
                    // if the interval is negative, add an entire day
                    toTimeD = Config.FORMAT_TIME_UI.parse(timeString.toString());
                    rj.setInterval(toTimeD.getTime() - fromTimeD.getTime());
                    if (rj.getInterval() < 0)
                        rj.setInterval(rj.getInterval() + 24 * 60 * 60 * 1000);
                    if (rj.getInterval() > Config.MAX_RECUR_INTERVAL) {
                        // Toast.makeText(getActivity(),
                        // R.string.interval_too_large,
                        // Toast.LENGTH_SHORT).show();
                        ValidatorHelper.highlight(getSherlockActivity(), toTime,
                                getResources().getString(R.string.interval_too_large));
                        return;
                    }

                } catch (ParseException e) {
                    // Toast.makeText(getActivity(),
                    // R.string.to_time_field_empty,
                    // Toast.LENGTH_SHORT).show();
                    ValidatorHelper.highlight(getSherlockActivity(), toTime,
                            getResources().getString(R.string.to_time_field_empty));
                    return;
                }
            }

            if (!eu.trentorise.smartcampus.jp.helper.Utils.validFromDateTimeToDateTime(fromDateD, fromTimeD,
                    toDateD, toTimeD) && !alwaysCheckbox.isChecked()) {
                // Toast.makeText(getActivity(),
                // R.string.datetime_to_before_from,
                // Toast.LENGTH_SHORT).show();
                ValidatorHelper.highlight(getSherlockActivity(), toTime,
                        getResources().getString(R.string.datetime_to_before_from));
                return;
            }

            rj.setTransportTypes((TType[]) userPrefsHolder.getTransportTypes());
            rj.setRouteType(userPrefsHolder.getRouteType());

            /* set recurrence on the ui */
            rj.setRecurrence(new ArrayList<Integer>());
            ToggleButton tmpToggle = (ToggleButton) getView().findViewById(R.id.monday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(2);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.tuesday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(3);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.wednesday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(4);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.thursday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(5);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.friday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(6);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.saturday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(7);
            tmpToggle = (ToggleButton) getView().findViewById(R.id.sunday_toggle);
            if (tmpToggle.isChecked())
                rj.getRecurrence().add(1);

            if (rj.getRecurrence().isEmpty()) {
                ValidatorHelper.highlight(getSherlockActivity(), getView().findViewById(R.id.monday_toggle),
                        getResources().getString(R.string.no_days_selected));
                //               Toast.makeText(getActivity(), R.string.no_days_selected, Toast.LENGTH_SHORT).show();
                return;
            }

            FragmentTransaction fragmentTransaction = getSherlockActivity().getSupportFragmentManager()
                    .beginTransaction();
            Fragment fragment = new MyRecurItineraryFragment();
            Bundle b = new Bundle();
            b.putSerializable(MyRecurItineraryFragment.PARAMS, params);
            b.putBoolean(MyRecurItineraryFragment.PARAM_EDITING, true);

            fragment.setArguments(b);
            fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            fragmentTransaction.replace(Config.mainlayout, fragment, MonitorJourneyFragment.this.getTag());
            fragmentTransaction.addToBackStack(fragment.getTag());
            fragmentTransaction.commit();
            // SCAsyncTask<BasicRecurrentJourneyParameters, Void,
            // RecurrentJourney> task = new
            // SCAsyncTask<BasicRecurrentJourneyParameters, Void,
            // RecurrentJourney>(
            // getSherlockActivity(), new
            // PlanRecurJourneyProcessor(getSherlockActivity()));
            // /*creare i parametri per la chiamata*/
            // BasicRecurrentJourneyParameters parameters = new
            // BasicRecurrentJourneyParameters();
            // /*fill the params*/
            // parameters.setClientId(params.getClientId());
            // parameters.setData(rj);
            // parameters.setMonitor(monitorToggleBtn.isChecked());
            // parameters.setName(params.getName());
            // task.execute(parameters);
        }

    });

    // add listener on alwayscheck
    alwaysCheckbox = (CheckBox) getView().findViewById(R.id.always_checkbox);
    alwaysCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                // disable the toDate
                toDate.setEnabled(false);
            } else {
                // enable the toDate
                toDate.setEnabled(true);

            }
        }
    });

    monitorLayout = (LinearLayout) getView().findViewById(R.id.myitinerary_toggle_layout);
    if (params.getClientId() != null) {
        monitorLayout.setVisibility(View.VISIBLE);
        monitorToggleBtn = (ToggleButton) getView().findViewById(R.id.myitinerary_toggle);
        TextView monitorLabel = (TextView) getView().findViewById(R.id.myitinerary_monitor_label);

        // monitorToggleBtn.setChecked(myItinerary.isMonitor());

        monitorToggleBtn.setOnCheckedChangeListener(null);
        monitorToggleBtn.setChecked(params.isMonitor());

        if (params.isMonitor()) {
            monitorToggleBtn.setBackgroundResource(R.drawable.ic_monitor_on);
            monitorLabel.setText(getString(R.string.monitor_on));
            monitorLabel.setTextAppearance(getSherlockActivity(), R.style.label_jp);

        } else {
            monitorToggleBtn.setBackgroundResource(R.drawable.ic_monitor_off);
            monitorLabel.setText(getString(R.string.monitor_off));
            monitorLabel.setTextAppearance(getSherlockActivity(), R.style.label_black_jp);

        }

        monitorToggleBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                SCAsyncTask<String, Void, Boolean> task = new SCAsyncTask<String, Void, Boolean>(
                        getSherlockActivity(), new MonitorMyRecItineraryProcessor(getSherlockActivity()));
                task.execute(Boolean.toString(isChecked), params.getClientId());
            }
        });
    } else
        monitorLayout.setVisibility(View.GONE);
}

From source file:eu.trentorise.smartcampus.jp.PlanNewJourneyFragment.java

protected void setUpPreferenceControls() {
    userPrefs = getSherlockActivity().getSharedPreferences(Config.USER_PREFS, Context.MODE_PRIVATE);

    if (userPrefsHolder == null) {
        userPrefsHolder = PrefsHelper.sharedPreferences2Holder(userPrefs);
    }/*ww  w .  j  a  va2s . c om*/

    final View userPrefsLayout = (View) getView().findViewById(R.id.plannew_userprefs);
    PrefsHelper.buildUserPrefsView(getSherlockActivity(), userPrefsHolder, userPrefsLayout);

    View useCustomPrefsToggleBtn = getView().findViewById(R.id.plannew_options);

    useCustomPrefsToggleBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            ImageView imgv = (ImageView) getView().findViewById(R.id.plannew_options_toggle);
            if (!userPrefsLayout.isShown()) {
                userPrefsLayout.setVisibility(View.VISIBLE);
                imgv.setImageResource(R.drawable.ic_navigation_expand);
            } else {
                userPrefsLayout.setVisibility(View.GONE);
                imgv.setImageResource(R.drawable.ic_navigation_next_item);
            }
        }
    });
}

From source file:org.catrobat.catroid.uitest.util.UiTestUtils.java

public static boolean waitForShownState(Solo solo, final View view, final boolean wantedState) {
    boolean result = solo.waitForCondition(new Condition() {
        public boolean isSatisfied() {
            return view.isShown() == wantedState;
        }//from w  w  w .java 2s.c  o m
    }, 500);

    if (!result) {
        fail("Condition is not satisfied before timeout. wantedState: " + Boolean.valueOf(wantedState));
    }

    return wantedState;
}

From source file:com.taobao.weex.devtools.inspector.protocol.module.DOM.java

@ChromeDevtoolsMethod
public GetBoxModelResponse getBoxModel(JsonRpcPeer peer, JSONObject params) {
    GetBoxModelResponse response = new GetBoxModelResponse();
    final BoxModel model = new BoxModel();
    final GetBoxModelRequest request = mObjectMapper.convertValue(params, GetBoxModelRequest.class);

    if (request.nodeId == null) {
        return null;
    }//  ww w. j  a  v a 2  s .co  m

    response.model = model;

    mDocument.postAndWait(new Runnable() {
        @Override
        public void run() {
            final Object elementForNodeId = mDocument.getElementForNodeId(request.nodeId);

            if (elementForNodeId == null) {
                LogUtil.w("Failed to get style of an element that does not exist, nodeid=" + request.nodeId);
                return;
            }

            mDocument.getElementStyles(elementForNodeId, new StyleAccumulator() {
                @Override
                public void store(String name, String value, boolean isDefault) {
                    double left = 0;
                    double right = 0;
                    double top = 0;
                    double bottom = 0;

                    double paddingLeft = 0;
                    double paddingRight = 0;
                    double paddingTop = 0;
                    double paddingBottom = 0;

                    double marginLeft = 0;
                    double marginRight = 0;
                    double marginTop = 0;
                    double marginBottom = 0;

                    double borderLeftWidth = 0;
                    double borderRightWidth = 0;
                    double borderTopWidth = 0;
                    double borderBottomWidth = 0;

                    View view = null;
                    if (isNativeMode()) {
                        if (elementForNodeId instanceof View) {
                            view = (View) elementForNodeId;
                        }
                    } else {
                        if (elementForNodeId instanceof WXComponent) {
                            view = ((WXComponent) elementForNodeId).getHostView();
                        }
                    }

                    if (view != null && view.isShown()) {
                        float scale = ScreencastDispatcher.getsBitmapScale();
                        model.width = view.getWidth();
                        model.height = view.getHeight();
                        if (!DOM.isNativeMode()) {
                            model.width = (int) (model.width * 750 / WXViewUtils.getScreenWidth() + 0.5);
                            model.height = (int) (model.height * 750 / WXViewUtils.getScreenWidth() + 0.5);
                        }

                        int[] location = new int[2];
                        view.getLocationOnScreen(location);

                        left = location[0] * scale;
                        top = location[1] * scale;
                        right = left + view.getWidth() * scale;
                        bottom = top + view.getHeight() * scale;

                        paddingLeft = view.getPaddingLeft() * scale;
                        paddingTop = view.getPaddingTop() * scale;
                        paddingRight = view.getPaddingRight() * scale;
                        paddingBottom = view.getPaddingBottom() * scale;

                        if (view instanceof ViewGroup) {
                            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
                            if (layoutParams != null) {
                                if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
                                    ViewGroup.MarginLayoutParams margins = (ViewGroup.MarginLayoutParams) layoutParams;
                                    marginLeft = margins.leftMargin * scale;
                                    marginTop = margins.topMargin * scale;
                                    marginRight = margins.rightMargin * scale;
                                    marginBottom = margins.bottomMargin * scale;
                                }
                            }
                        }
                    }
                    ArrayList<Double> padding = new ArrayList<>(8);
                    padding.add(left + borderLeftWidth);
                    padding.add(top + borderTopWidth);
                    padding.add(right - borderRightWidth);
                    padding.add(top + borderTopWidth);
                    padding.add(right - borderRightWidth);
                    padding.add(bottom - borderBottomWidth);
                    padding.add(left + borderLeftWidth);
                    padding.add(bottom - borderBottomWidth);
                    model.padding = padding;

                    ArrayList<Double> content = new ArrayList<>(8);
                    content.add(left + borderLeftWidth + paddingLeft);
                    content.add(top + borderTopWidth + paddingTop);
                    content.add(right - borderRightWidth - paddingRight);
                    content.add(top + borderTopWidth + paddingTop);
                    content.add(right - borderRightWidth - paddingRight);
                    content.add(bottom - borderBottomWidth - paddingBottom);
                    content.add(left + borderLeftWidth + paddingLeft);
                    content.add(bottom - borderBottomWidth - paddingBottom);
                    model.content = content;

                    ArrayList<Double> border = new ArrayList<>(8);
                    border.add(left);
                    border.add(top);
                    border.add(right);
                    border.add(top);
                    border.add(right);
                    border.add(bottom);
                    border.add(left);
                    border.add(bottom);
                    model.border = border;

                    ArrayList<Double> margin = new ArrayList<>(8);
                    margin.add(left - marginLeft);
                    margin.add(top - marginTop);
                    margin.add(right + marginRight);
                    margin.add(top - marginTop);
                    margin.add(right + marginRight);
                    margin.add(bottom + marginBottom);
                    margin.add(left - marginLeft);
                    margin.add(bottom + marginBottom);
                    model.margin = margin;
                }
            });
        }
    });

    return response;
}

From source file:vc908.stickerfactory.ui.advancedrecyclerview.swipeable.ItemSlidingAnimator.java

private boolean slideToOutsideOfWindowInternal(RecyclerView.ViewHolder holder, boolean toLeft,
        boolean shouldAnimate, long duration) {
    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }/*from   w  ww .  ja  va  2s. c o m*/

    final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView();
    final ViewGroup parent = (ViewGroup) containerView.getParent();

    if (parent == null) {
        return false;
    }

    final int left = containerView.getLeft();
    final int right = containerView.getRight();
    final int width = right - left;
    final boolean parentIsShown = parent.isShown();

    parent.getWindowVisibleDisplayFrame(mTmpRect);

    final int translateX;
    if ((width == 0) || !parentIsShown) {
        // not measured yet or not shown
        translateX = (toLeft) ? (-mTmpRect.width()) : (mTmpRect.width());
        shouldAnimate = false;
    } else {
        parent.getLocationInWindow(mTmpLocation);

        if (toLeft) {
            translateX = -(mTmpLocation[0] + width);
        } else {
            translateX = mTmpRect.width() - (mTmpLocation[0] - left);
        }
    }

    if (shouldAnimate) {
        shouldAnimate = containerView.isShown();
    }

    duration = (shouldAnimate) ? duration : 0;

    return animateSlideInternalCompat(holder, translateX, duration,
            mSlideToOutsideOfWindowAnimationInterpolator);
}

From source file:com.example.carlitos.swipeitemrecycler.view.animation.swipe_item.swipeable.ItemSlidingAnimator.java

private boolean slideToOutsideOfWindowInternal(RecyclerView.ViewHolder holder, int dir, boolean shouldAnimate,
        long duration, SwipeFinishInfo swipeFinish) {

    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }//from  www. ja v  a2s .c  o  m

    final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView();
    final ViewGroup parent = (ViewGroup) containerView.getParent();

    if (parent == null) {
        return false;
    }

    final int left = containerView.getLeft();
    final int right = containerView.getRight();
    final int top = containerView.getTop();
    final int bottom = containerView.getBottom();
    final int width = right - left;
    final int height = bottom - top;
    final boolean parentIsShown = parent.isShown();

    parent.getWindowVisibleDisplayFrame(mTmpRect);
    final int windowWidth = mTmpRect.width();
    final int windowHeight = mTmpRect.height();

    int translateX = 0;
    int translateY = 0;

    if ((width == 0) || (height == 0) || !parentIsShown) {
        // not measured yet or not shown
        switch (dir) {
        case DIR_LEFT:
            translateX = -windowWidth;
            break;
        case DIR_UP:
            translateY = -windowHeight;
            break;
        case DIR_RIGHT:
            translateX = windowWidth;
            break;
        case DIR_DOWN:
            translateY = windowHeight;
            break;
        default:
            break;
        }
        shouldAnimate = false;
    } else {
        parent.getLocationInWindow(mTmpLocation);
        final int x = mTmpLocation[0];
        final int y = mTmpLocation[1];

        switch (dir) {
        case DIR_LEFT:
            translateX = -(x + width);
            break;
        case DIR_UP:
            translateY = -(y + height);
            break;
        case DIR_RIGHT:
            translateX = windowWidth - (x - left);
            break;
        case DIR_DOWN:
            translateY = windowHeight - (y - top);
            break;
        default:
            break;
        }
    }

    if (shouldAnimate) {
        shouldAnimate = containerView.isShown();
    }

    duration = (shouldAnimate) ? duration : 0;

    boolean horizontal = (dir == DIR_LEFT || dir == DIR_RIGHT);
    return animateSlideInternalCompat(holder, horizontal, translateX, translateY, duration,
            mSlideToOutsideOfWindowAnimationInterpolator, swipeFinish);
}

From source file:com.mobiletin.inputmethod.indic.LatinIME.java

@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);

    final SettingsValues settingsValues = mSettings.getCurrent();
    final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
    if (visibleKeyboardView == null || !hasSuggestionStripView()) {
        return;//from  w w  w. ja v  a  2 s  .c  o  m
    }
    final int inputHeight = mInputView.getHeight();
    final boolean hasHardwareKeyboard = settingsValues.mHasHardwareKeyboard;
    if (hasHardwareKeyboard && visibleKeyboardView.getVisibility() == View.GONE) {
        // If there is a hardware keyboard and a visible software keyboard view has been hidden,
        // no visual element will be shown on the screen.
        outInsets.touchableInsets = inputHeight;
        outInsets.visibleTopInsets = inputHeight;
        return;
    }

    final int suggestionsHeight = (!mKeyboardSwitcher.isShowingEmojiPalettes()
            && mSuggestionStripView.getVisibility() == View.VISIBLE) ? mSuggestionStripView.getHeight() : 0;
    final int visibleTopY = inputHeight - visibleKeyboardView.getHeight() - suggestionsHeight
            - adView.getHeight();
    mSuggestionStripView.setMoreSuggestionsHeight(visibleTopY);

    // Need to set touchable region only if a keyboard view is being shown.
    if (visibleKeyboardView.isShown()) {
        final int touchLeft = 0;
        final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
        final int touchRight = visibleKeyboardView.getWidth();
        final int touchBottom = inputHeight
                // Extend touchable region below the keyboard.
                + EXTENDED_TOUCHABLE_REGION_HEIGHT;
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
    }
    outInsets.contentTopInsets = visibleTopY;
    outInsets.visibleTopInsets = visibleTopY;

}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (DEBUG)//from w  w w . j av  a 2s  .c o m
        Logger.LogDebug("OpenExplorer.onKeyUp(" + keyCode + "," + event + ")");
    if (event.getAction() != KeyEvent.ACTION_UP)
        return super.onKeyUp(keyCode, event);
    if (MenuUtils.getMenuShortcut(event) != null) {
        if (getCurrentFocus() != null) {
            View cf = getCurrentFocus();
            if (cf instanceof TextView)
                return false;
        }
        MenuItem item = MenuUtils.getMenuShortcut(event);
        if (item != null)
            if (onOptionsItemSelected(item)) {
                showToast(item.getTitle(), Toast.LENGTH_SHORT);
                return true;
            }
    }
    if (keyCode == KeyEvent.KEYCODE_MENU && USE_PRETTY_MENUS) {
        View more = findViewById(R.id.menu_more);
        if (more != null && more.isShown() && more.isClickable() && more.performClick()) {
            Logger.LogDebug("!SHOULD BE HERE!");
            return true;
        } else {
            Logger.LogWarning("Couldn't find \"More Menu\"!");
            MenuBuilder menu = new MenuBuilder(this);
            getSelectedFragment().onCreateOptionsMenu(menu, getMenuInflater());
            getMenuInflater().inflate(R.menu.global, menu);
            onPrepareOptionsMenu(menu);
            showMenu(menu, getCurrentFocus(), true);
        }
    } else if (keyCode == KeyEvent.KEYCODE_BOOKMARK) {
        OpenPath path = getDirContentFragment(false).getPath();
        if (mBookmarks.hasBookmark(path))
            addBookmark(path);
        else
            removeBookmark(path);
    } else if (keyCode >= KeyEvent.KEYCODE_1 && keyCode <= KeyEvent.KEYCODE_9) {
        int pos = keyCode - KeyEvent.KEYCODE_1;
        if (mToolbarButtons != null) {
            if (pos < mToolbarButtons.getChildCount() && mToolbarButtons.getChildAt(pos).performClick())
                return true;
            return false;
        }
        if (mOptsMenu != null && pos < mOptsMenu.size())
            return onOptionsItemSelected(mOptsMenu.getItem(pos));
        if (mMainMenu != null && pos < mMainMenu.size())
            return onOptionsItemSelected(mMainMenu.getItem(pos));
    }
    /*
    if (keyCode == KeyEvent.KEYCODE_BACK) {
       if (mBackQuit) {
    return super.onKeyUp(keyCode, event);
       } else {
    Toast.makeText(this, "Press back again to quit", Toast.LENGTH_SHORT).show();
    mBackQuit = true;
    return true;
       }      
    }*/
    return super.onKeyUp(keyCode, event);
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

public boolean onClick(int id, MenuItem item, View from) {
    super.onClick(id);
    if (from == null || !from.isShown())
        from = findViewById(id);//from   w  w  w  .j a  v a 2 s .  c o  m
    if (id != R.id.title_icon && id != android.R.id.home)
        ;
    toggleBookmarks(false);
    OpenFragment f = getSelectedFragment();
    if (f != null && f.onClick(id, from))
        return true;
    if (item != null && f != null && f.onOptionsItemSelected(item))
        return true;
    if (DEBUG)
        Logger.LogDebug("OpenExplorer.onClick(0x" + Integer.toHexString(id) + "," + item + "," + from + ")");
    switch (id) {
    case R.id.menu_debug:
        debugTest();
        break;
    case R.id.title_icon:
    case android.R.id.home:
        toggleBookmarks();
        return true;

    case R.id.menu_multi:
        if (getClipboard().isMultiselect()) {
            getClipboard().stopMultiselect();
            //getClipboard().clear();
            if (!BEFORE_HONEYCOMB && mActionMode != null)
                ((ActionMode) mActionMode).finish();
            return true;
        }

        if (BEFORE_HONEYCOMB || !USE_ACTIONMODE) {
            getClipboard().startMultiselect();
        } else {
            mActionMode = startActionMode(new ActionMode.Callback() {

                public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                    return false;
                }

                public void onDestroyActionMode(ActionMode mode) {
                    getClipboard().clear();
                    mActionMode = null;
                }

                public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                    mode.setTitle(getString(R.string.s_menu_multi) + ": " + getClipboard().size() + " "
                            + getString(R.string.s_files));
                    mode.getMenuInflater().inflate(R.menu.multiselect, menu);
                    //MenuUtils.setMenuVisible(menu, false, R.id.menu_context_paste, R.id.menu_context_unzip);
                    getDirContentFragment(true).changeMultiSelectState(true);
                    return true;
                }

                public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                    if (getClipboard().size() < 1) {
                        mode.finish();
                        return true;
                    }
                    OpenPath file = getClipboard().get(0); //getMultiSelectHandler().getSelectedFiles();

                    getClipboard().clear();

                    return getDirContentFragment(false).executeMenu(item.getItemId(), mode, file);
                }
            });
        }
        return true;

    case R.id.menu_view_carousel:
        changeViewMode(OpenExplorer.VIEW_CAROUSEL, true);
        return true;

    case R.id.menu_view_grid:
        changeViewMode(OpenExplorer.VIEW_GRID, true);
        return true;

    case R.id.menu_view_list:
        changeViewMode(OpenExplorer.VIEW_LIST, true);
        return true;

    case R.id.menu_view_fullscreen:
        getPreferences().setSetting("global", "pref_fullscreen",
                !getPreferences().getSetting("global", "pref_fullscreen", false));
        goHome();
        return true;

    case R.id.menu_view_split:
        setSetting("pref_basebar", !USE_SPLIT_ACTION_BAR);
        goHome();
        return true;

    //case R.id.menu_global_ops_text:
    //case R.id.menu_global_ops_icon:
    case R.id.title_ops:
        refreshOperations();
        showLogFrag(mOpsFragment, true);
        checkTitleSeparator();
        return true;

    case R.id.title_log:
        if (mLogFragment == null)
            mLogFragment = new LogViewerFragment();
        showLogFrag(mLogFragment, true);
        sendToLogView(null, 0);
        return true;

    /*case R.id.menu_root:
    if(RootManager.Default.isRoot())
    {
       getPreferences().setSetting("global", "pref_root", false);
       showToast(getString(R.string.s_menu_root_disabled));
       RootManager.Default.exitRoot();
       item.setChecked(false);
    } else
    {
       if(RootManager.Default.isRoot() || RootManager.Default.requestRoot())
       {
          getPreferences().setSetting("global", "pref_root", true);
          showToast(getString(R.string.s_menu_root) + "!");
          item.setTitle(getString(R.string.s_menu_root) + "!");
       } else {
          item.setChecked(false);
          showToast("Unable to achieve root.");
       }
    }
    return true;
            
    case R.id.menu_flush:
    ThumbnailCreator.flushCache(getApplicationContext(), true);
    OpenPath.flushDbCache();
    goHome();
    return true;*/

    case R.id.menu_refresh:
        ContentFragment content = getDirContentFragment(true);
        if (content != null) {
            if (DEBUG && IS_DEBUG_BUILD)
                Logger.LogDebug("Refreshing " + content.getPath().getPath());
            FileManager.removeOpenCache(content.getPath().getPath());
            content.getPath().deleteFolderFromDb();
            content.runUpdateTask(true);
            changePath(content.getPath(), false, true);
        }
        mBookmarks.refresh();
        return true;

    case R.id.menu_settings:
        showPreferences(null);
        return true;

    case R.id.menu_search:
        onSearchRequested();
        return true;

    /*case R.id.menu_favorites:
    toggleBookmarks();
    return true;*/

    case R.id.menu_multi_all_delete:
        DialogHandler.showConfirmationDialog(this,
                getResources().getString(R.string.s_confirm_delete,
                        getClipboard().getCount() + " " + getResources().getString(R.string.s_files)),
                getResources().getString(R.string.s_menu_delete_all), new DialogInterface.OnClickListener() { // yes
                    public void onClick(DialogInterface dialog, int which) {
                        getEventHandler().deleteFile(getClipboard(), OpenExplorer.this, false);
                    }
                });
        break;

    case R.id.menu_multi_all_clear:
        getClipboard().clear();
        return true;

    case R.id.menu_multi_all_copy:
        getClipboard().DeleteSource = false;
        getDirContentFragment(false).executeMenu(R.id.content_paste, null,
                getDirContentFragment(false).getPath());
        break;

    case R.id.menu_multi_all_move:
        getClipboard().DeleteSource = true;
        getDirContentFragment(false).executeMenu(R.id.content_paste, null,
                getDirContentFragment(false).getPath());
        break;

    case R.id.title_paste:
    case R.id.title_paste_icon:
    case R.id.title_paste_text:
    case R.id.content_paste:
        //if(BEFORE_HONEYCOMB)
        getClipboard().setCurrentPath(getCurrentPath());
        onClipboardDropdown(from);
        return true;

    //getDirContentFragment(false).executeMenu(R.id.menu_paste, null, mLastPath, mClipboard);
    //return true;

    case R.id.menu_about:
        DialogHandler.showAboutDialog(this);
        return true;

    case R.id.menu_exit:
        DialogHandler.showConfirmationDialog(this, getString(R.string.s_alert_exit),
                getString(R.string.s_menu_exit), getPreferences(), "exit",
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                });
        return true;
    case R.id.menu_more:
        showMenu(mOptsMenu, ViewUtils.getFirstView(this, R.id.menu_more, R.id.base_bar, R.id.title_buttons,
                android.R.id.home), true);
        return true;

    default:
        if (f instanceof ContentFragment) {
            ContentFragment cf = (ContentFragment) f;
            if (item.getMenuInfo() != null && cf.onContextItemSelected(item))
                return true;
            else if (cf.onClick(id, from))
                return true;
            else if (cf.onOptionsItemSelected(item))
                return true;
            return cf.executeMenu(id, null, getDirContentFragment(false).getPath());
        } else if (f instanceof TextEditorFragment)
            ((TextEditorFragment) f).onClick(id, from);
        else if (f.onOptionsItemSelected(item))
            return true;
    }

    //showToast("oops");
    return false;
    //return super.onOptionsItemSelected(item);
}