Example usage for android.view KeyEvent getAction

List of usage examples for android.view KeyEvent getAction

Introduction

In this page you can find the example usage for android.view KeyEvent getAction.

Prototype

public final int getAction() 

Source Link

Document

Retrieve the action of this key event.

Usage

From source file:com.mobicage.rogerthat.plugins.friends.RecommendServiceActivity.java

private void configureMailView() {
    T.UI();//from   ww w.jav a2  s.c o m
    final AutoCompleteTextView emailText = (AutoCompleteTextView) findViewById(R.id.recommend_email_text_field);
    emailText.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, new ArrayList<String>()));
    emailText.setThreshold(1);

    if (mService.isPermitted(Manifest.permission.READ_CONTACTS)) {
        mService.postAtFrontOfBIZZHandler(new SafeRunnable() {

            @SuppressWarnings("unchecked")
            @Override
            protected void safeRun() throws Exception {
                L.d("RecommendServiceActivity getEmailAddresses");
                List<String> emailList = ContactListHelper.getEmailAddresses(RecommendServiceActivity.this);
                ArrayAdapter<String> a = (ArrayAdapter<String>) emailText.getAdapter();
                for (int i = 0; i < emailList.size(); i++) {
                    a.add(emailList.get(i));
                }
                a.notifyDataSetChanged();
                L.d("RecommendServiceActivity gotEmailAddresses");
            }
        });
    }

    final SafeViewOnClickListener onClickListener = new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            String email = emailText.getText().toString().trim();
            if (RegexPatterns.EMAIL.matcher(email).matches()) {
                mFriendsPlugin.shareService(mServiceEmail, email);
                emailText.setText(null);
                UIUtils.hideKeyboard(RecommendServiceActivity.this, emailText);

                AlertDialog.Builder builder = new AlertDialog.Builder(RecommendServiceActivity.this);
                builder.setMessage(R.string.service_recommendation_sent);
                builder.setPositiveButton(R.string.rogerthat, null);
                builder.create().show();
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(RecommendServiceActivity.this);
                builder.setMessage(R.string.registration_email_not_valid);
                builder.setPositiveButton(R.string.rogerthat, null);
                builder.create().show();
            }
        }
    };

    ((Button) findViewById(R.id.recommend_email_button)).setOnClickListener(onClickListener);

    emailText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
                    && event.getAction() == KeyEvent.ACTION_DOWN)) {
                onClickListener.onClick(view);
                return true;
            }
            return false;
        }
    });
}

From source file:dev.datvt.cloudtracks.sound_cloud.LocalTracksFragment.java

private void addEvent() {
    search_et.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                ToolsHelper.hideKeyBoard(getActivity());
                String query = search_et.getText().toString();
                if (query != null) {
                    if (query.length() > 1 && baseLocal.size() > 0) {
                        ArrayList<Track> tmp = new ArrayList<>();
                        for (int z = 0; z < baseLocal.size(); z++) {
                            if (baseLocal.get(z).title.toLowerCase().contains(query.toLowerCase())) {
                                tmp.add(baseLocal.get(z));
                            }//from   ww w . ja  v  a  2 s  .c  o  m
                        }

                        if (tmp.size() > 0) {
                            localTracks = tmp;
                            setUpList(localTracks);
                        } else {
                            ToolsHelper.toast(ctx, getString(R.string.nothing_found));
                        }
                    }
                }
                return true;
            }
            return false;
        }
    });

    search_et.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            final StringBuilder sb = new StringBuilder(charSequence.length());
            sb.append(charSequence);
            String query = sb.toString();

            if (query != null && baseLocal != null) {
                if (query.length() > 0 && baseLocal.size() > 0) {
                    ArrayList<Track> tmp = new ArrayList<Track>();

                    for (int z = 0; z < baseLocal.size(); z++) {
                        if (baseLocal.get(z).title.toLowerCase().contains(query.toLowerCase())) {
                            tmp.add(baseLocal.get(z));
                        }
                    }

                    if (tmp.size() > 0) {
                        localTracks = tmp;
                        setUpList(localTracks);
                    }
                    //                        else {
                    //                            ToolsHelper.toast(ctx, getString(R.string.nothing_found));
                    //                        }
                }
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    ref.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            try {
                getAllSongs();
                setUpList(localTracks);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

    back.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ref.setVisibility(View.GONE);
            lnBack.setVisibility(View.GONE);
            mm.setVisibility(View.VISIBLE);
            showMenus();
        }
    });
}

From source file:butter.droid.tv.fragments.TVPlaybackOverlayFragment.java

@Override
public boolean handleInputEvent(@NonNull InputEvent event) {
    if (event instanceof KeyEvent) {
        KeyEvent keyEvent = (KeyEvent) event;
        if (keyEvent.getKeyCode() != KeyEvent.KEYCODE_DPAD_CENTER)
            return false;
        if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
            if (mFastForwardAction != null && mSelectedActionId == mFastForwardAction.getId()) {
                if (keyEvent.getRepeatCount() == 0) {
                    mCurrentMode = MODE_FAST_FORWARD;
                    invokeFastForwardAction();
                }// w w w. ja  v  a  2s. c  o  m
            } else if (mRewindAction != null && mSelectedActionId == mRewindAction.getId()) {
                if (keyEvent.getRepeatCount() == 0) {
                    mCurrentMode = MODE_REWIND;
                    invokeRewindAction();
                }
            }
        } else if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
            mCurrentMode = MODE_NOTHING;
        }
    }
    return false;
}

From source file:com.cloudexplorers.plugins.childBrowser.ChildBrowser.java

/**
 * Display a new browser with the specified URL.
 * //from  ww  w .  ja va  2  s  . c o m
 * @param url
 *          The url to load.
 * @param jsonObject
 */
public String showWebPage(final String url, JSONObject options) {
    // Determine if we should hide the location bar.
    if (options != null) {
        showLocationBar = options.optBoolean("showLocationBar", true);
    }

    // Create dialog in new thread
    Runnable runnable = new Runnable() {
        /**
         * Convert our DIP units to Pixels
         * 
         * @return int
         */
        private int dpToPixels(int dipValue) {
            int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue,
                    cordova.getActivity().getResources().getDisplayMetrics());

            return value;
        }

        public void run() {
            // Let's create the main dialog
            dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
            dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                public void onDismiss(DialogInterface dialog) {
                    try {
                        JSONObject obj = new JSONObject();
                        obj.put("type", CLOSE_EVENT);

                        sendUpdate(obj, false);
                    } catch (JSONException e) {
                        Log.d(LOG_TAG, "Should never happen");
                    }
                }
            });

            // Main container layout
            LinearLayout main = new LinearLayout(cordova.getActivity());
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout
            RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
            toolbar.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, this.dpToPixels(44)));
            toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.TOP);

            // Action Button Container layout
            RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
            actionButtonContainer.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
            actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
            actionButtonContainer.setId(1);

            // Back button
            ImageButton back = new ImageButton(cordova.getActivity());
            RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
            backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            back.setLayoutParams(backLayoutParams);
            back.setContentDescription("Back Button");
            back.setId(2);
            try {
                back.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_left.png"));
            } catch (IOException e) {
                Log.e(LOG_TAG, e.getMessage(), e);
            }
            back.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goBack();
                }
            });

            // Forward button
            ImageButton forward = new ImageButton(cordova.getActivity());
            RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
            forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
            forward.setLayoutParams(forwardLayoutParams);
            forward.setContentDescription("Forward Button");
            forward.setId(3);
            try {
                forward.setImageBitmap(loadDrawable("www/childbrowser/icon_arrow_right.png"));
            } catch (IOException e) {
                Log.e(LOG_TAG, e.getMessage(), e);
            }
            forward.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goForward();
                }
            });

            // Edit Text Box
            edittext = new EditText(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setId(4);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
            edittext.setInputType(InputType.TYPE_NULL); // Will not except input...
                                                        // Makes the text
                                                        // NON-EDITABLE
            edittext.setOnKeyListener(new View.OnKeyListener() {
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    // If the event is a key-down event on the "enter" button
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                        navigate(edittext.getText().toString());
                        return true;
                    }
                    return false;
                }
            });

            // Close button
            ImageButton close = new ImageButton(cordova.getActivity());
            RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
            closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            close.setLayoutParams(closeLayoutParams);
            forward.setContentDescription("Close Button");
            close.setId(5);
            try {
                close.setImageBitmap(loadDrawable("www/childbrowser/icon_close.png"));
            } catch (IOException e) {
                Log.e(LOG_TAG, e.getMessage(), e);
            }
            close.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    closeDialog();
                }
            });

            // WebView
            webview = new WebView(cordova.getActivity());
            webview.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
            webview.setWebChromeClient(new WebChromeClient());
            WebViewClient client = new ChildBrowserClient(edittext);
            webview.setWebViewClient(client);
            WebSettings settings = webview.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(true);
            settings.setPluginsEnabled(true);
            settings.setDomStorageEnabled(true);

            webview.loadUrl(url);
            webview.setId(6);
            webview.getSettings().setLoadWithOverviewMode(true);
            webview.getSettings().setUseWideViewPort(true);
            webview.getSettings().setJavaScriptEnabled(true);
            webview.getSettings().setPluginsEnabled(true);

            webview.requestFocus();
            webview.requestFocusFromTouch();

            // Add the back and forward buttons to our action button container
            // layout
            actionButtonContainer.addView(back);
            actionButtonContainer.addView(forward);

            // Add the views to our toolbar
            toolbar.addView(actionButtonContainer);
            toolbar.addView(edittext);
            toolbar.addView(close);

            // Don't add the toolbar if its been disabled
            if (getShowLocationBar()) {
                // Add our toolbar to our main view/layout
                main.addView(toolbar);
            }

            // Add our webview to our main view/layout
            main.addView(webview);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.FILL_PARENT;
            lp.height = WindowManager.LayoutParams.FILL_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
        }

        private Bitmap loadDrawable(String filename) throws java.io.IOException {
            InputStream input = cordova.getActivity().getAssets().open(filename);
            return BitmapFactory.decodeStream(input);
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}

From source file:net.bluecarrot.lite.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            if (webViewFacebook.canGoBack()) {
                webViewFacebook.goBack();
            } else {
                // exit
                finish();//  w  w  w.j a v a2  s.  com
            }
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.github.akinaru.rfdroid.activity.BtDevicesActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {

        if (scanningListView.getVisibility() == View.VISIBLE) {
            onBackPressed();//from   w ww.ja v a 2s .  c o m
        } else {
            if (currentService.isScanning()) {
                hideProgressBar();
                currentService.stopScan();
            }
            mScanIntervalSeekbar.setVisibility(View.GONE);
            mWindowIntervalSeekbar.setVisibility(View.GONE);
            scanningListView.setVisibility(View.VISIBLE);
            if (deviceNameTv != null)
                deviceNameTv.setVisibility(View.GONE);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:com.hitesh_sahu.retailapp.view.fragment.ProductDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.frag_product_detail, container, false);
    scrollView = (ScrollView) rootView;//from w w w  .j  av a2s.  co  m
    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setTitleTextColor(Color.WHITE);

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    similarProductsPager = (ClickableViewPager) rootView.findViewById(R.id.similar_products_pager);

    topSellingPager = (ClickableViewPager) rootView.findViewById(R.id.top_selleing_pager);

    itemSellPrice = ((TextView) rootView.findViewById(R.id.category_discount));

    quanitity = ((TextView) rootView.findViewById(R.id.iteam_amount));

    itemName = ((TextView) rootView.findViewById(R.id.product_name));

    itemdescription = ((TextView) rootView.findViewById(R.id.product_description));

    itemImage = (ImageView) rootView.findViewById(R.id.product_image);

    fillProductData();
    TextView addItem = (TextView) rootView.findViewById(R.id.add_item);
    FocusPin.with(getContext()).into(addItem).scrollView(scrollView).create();

    addItem.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            FocusPin.with(getContext()).destroy();
            /*if (null != mFrameLayout && mFrameLayout.isActivated()) {
                mWindowManager.removeViewImmediate(mFrameLayout);
                mFrameLayout.setActivated(false);
                ViewTreeObserver observer = scrollView.getViewTreeObserver();
                observer.removeOnScrollChangedListener(onScrollChangedListener);
            }*/
            if (isFromCart) {

                //Update Quantity on shopping List
                CenterRepository.getCenterRepository().getListOfProductsInShoppingList().get(productListNumber)
                        .setQuantity(String.valueOf(

                                Integer.valueOf(CenterRepository.getCenterRepository()
                                        .getListOfProductsInShoppingList().get(productListNumber).getQuantity())
                                        + 1));

                //Update Ui
                quanitity.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .get(productListNumber).getQuantity());

                Utils.vibrate(getActivity());

                //Update checkout amount on screen
                ((ECartHomeActivity) getActivity()).updateCheckOutAmount(
                        BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                                .getListOfProductsInShoppingList().get(productListNumber).getSellMRP())),
                        true);

            } else {

                // current object
                Product tempObj = CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                        .get(subcategoryKey).get(productListNumber);

                // if current object is lready in shopping list
                if (CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .contains(tempObj)) {

                    // get position of current item in shopping list
                    int indexOfTempInShopingList = CenterRepository.getCenterRepository()
                            .getListOfProductsInShoppingList().indexOf(tempObj);

                    // increase quantity of current item in shopping
                    // list
                    if (Integer.parseInt(tempObj.getQuantity()) == 0) {

                        ((ECartHomeActivity) getContext()).updateItemCount(true);

                    }

                    // update quanity in shopping list
                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .get(indexOfTempInShopingList)
                            .setQuantity(String.valueOf(Integer.valueOf(tempObj.getQuantity()) + 1));

                    // update checkout amount
                    ((ECartHomeActivity) getContext())
                            .updateCheckOutAmount(
                                    BigDecimal.valueOf(Long.valueOf(
                                            CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                                                    .get(subcategoryKey).get(productListNumber).getSellMRP())),
                                    true);

                    // update current item quanitity
                    quanitity.setText(tempObj.getQuantity());

                } else {

                    ((ECartHomeActivity) getContext()).updateItemCount(true);

                    tempObj.setQuantity(String.valueOf(1));

                    quanitity.setText(tempObj.getQuantity());

                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList().add(tempObj);
                    ((ECartHomeActivity) getContext()).getCheckOutView();
                    ((ECartHomeActivity) getContext())
                            .updateCheckOutAmount(
                                    BigDecimal.valueOf(Long.valueOf(
                                            CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                                                    .get(subcategoryKey).get(productListNumber).getSellMRP())),
                                    true);

                }

                Utils.vibrate(getContext());

            }
        }

    });

    rootView.findViewById(R.id.remove_item).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (isFromCart)

            {

                if (Integer.valueOf(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .get(productListNumber).getQuantity()) > 2) {

                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .get(productListNumber).setQuantity(String.valueOf(

                                    Integer.valueOf(CenterRepository.getCenterRepository()
                                            .getListOfProductsInShoppingList().get(productListNumber)
                                            .getQuantity()) - 1));

                    quanitity.setText(CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .get(productListNumber).getQuantity());

                    ((ECartHomeActivity) getActivity()).updateCheckOutAmount(
                            BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                                    .getListOfProductsInShoppingList().get(productListNumber).getSellMRP())),
                            false);

                    Utils.vibrate(getActivity());
                } else if (Integer.valueOf(CenterRepository.getCenterRepository()
                        .getListOfProductsInShoppingList().get(productListNumber).getQuantity()) == 1) {
                    ((ECartHomeActivity) getActivity()).updateItemCount(false);

                    ((ECartHomeActivity) getActivity()).updateCheckOutAmount(
                            BigDecimal.valueOf(Long.valueOf(CenterRepository.getCenterRepository()
                                    .getListOfProductsInShoppingList().get(productListNumber).getSellMRP())),
                            false);

                    CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                            .remove(productListNumber);

                    if (Integer.valueOf(((ECartHomeActivity) getActivity()).getItemCount()) == 0) {

                        MyCartFragment.updateMyCartFragment(false);

                    }

                    Utils.vibrate(getActivity());

                }

            } else {

                Product tempObj = CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                        .get(subcategoryKey).get(productListNumber);

                if (CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                        .contains(tempObj)) {

                    int indexOfTempInShopingList = CenterRepository.getCenterRepository()
                            .getListOfProductsInShoppingList().indexOf(tempObj);

                    if (Integer.valueOf(tempObj.getQuantity()) != 0) {

                        CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                                .get(indexOfTempInShopingList)
                                .setQuantity(String.valueOf(Integer.valueOf(tempObj.getQuantity()) - 1));

                        ((ECartHomeActivity) getContext()).updateCheckOutAmount(
                                BigDecimal.valueOf(Long.valueOf(
                                        CenterRepository.getCenterRepository().getMapOfProductsInCategory()
                                                .get(subcategoryKey).get(productListNumber).getSellMRP())),
                                false);

                        quanitity.setText(CenterRepository.getCenterRepository()
                                .getListOfProductsInShoppingList().get(indexOfTempInShopingList).getQuantity());

                        Utils.vibrate(getContext());

                        if (Integer.valueOf(
                                CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                                        .get(indexOfTempInShopingList).getQuantity()) == 0) {

                            CenterRepository.getCenterRepository().getListOfProductsInShoppingList()
                                    .remove(indexOfTempInShopingList);

                            ((ECartHomeActivity) getContext()).updateItemCount(false);

                        }

                    }

                } else {

                }

            }

        }

    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                if (isFromCart) {

                    Utils.switchContent(R.id.frag_container, Utils.SHOPPING_LIST_TAG,
                            ((ECartHomeActivity) (getActivity())), AnimationType.SLIDE_UP);
                } else {

                    Utils.switchContent(R.id.frag_container, Utils.PRODUCT_OVERVIEW_FRAGMENT_TAG,
                            ((ECartHomeActivity) (getActivity())), AnimationType.SLIDE_RIGHT);
                }

            }
            return true;
        }
    });

    if (isFromCart) {

        similarProductsPager.setVisibility(View.GONE);

        topSellingPager.setVisibility(View.GONE);

    } else {
        showRecomondation();
    }

    return rootView;
}

From source file:org.bombusim.lime.fragments.ChatFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.chat, container, false);

    contactBar = (ContactBar) v.findViewById(R.id.contact_head);
    mMessageBox = (ChatEditText) v.findViewById(R.id.messageBox);
    mSendButton = (ImageButton) v.findViewById(R.id.sendButton);
    mSmileButton = (ImageButton) v.findViewById(R.id.smileButton);
    chatListView = (ListView) v.findViewById(R.id.chatListView);

    mChatActive = v.findViewById(R.id.chatActive);
    mChatInactive = v.findViewById(R.id.chatInactive);

    if (!getChatFragmentListener().isTabMode()) {
        contactBar.setVisibility(View.GONE);

        View abCustomView = getSherlockActivity().getSupportActionBar().getCustomView();

        contactBar = (ContactBar) abCustomView.findViewById(R.id.contactHeadActionbar);
        contactBar.removeBackground();//from w w w  . jav a2s  .c o m
    }

    registerForContextMenu(chatListView);
    enableTrackballTraversing();

    mSendButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            sendMessage();
        }
    });

    mSmileButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mMessageBox.showAddSmileDialog();
        }
    });

    //TODO: optional
    mMessageBox.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false; //filtering only KEY_DOWN

            if (keyCode != KeyEvent.KEYCODE_ENTER)
                return false;
            //if (event.isShiftPressed()) return false; //typing multiline messages with SHIFT+ENTER
            sendMessage();
            return true; //Key was processed
        }
    });

    mMessageBox.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (s.length() > 0)
                sendChatState(ChatStates.COMPOSING);
        }
    });

    //TODO: optional behavior
    //messageBox.setImeActionLabel("Send", EditorInfo.IME_ACTION_SEND); //Keeps IME opened
    mMessageBox.setImeActionLabel(getString(R.string.sendMessage), EditorInfo.IME_ACTION_DONE); //Closes IME

    mMessageBox.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            switch (actionId) {
            case EditorInfo.IME_ACTION_SEND:
                sendMessage();
                return true;
            case EditorInfo.IME_ACTION_DONE:
                sendMessage();
                return false; //let IME to be closed
            }
            return false;
        }
    });

    contactBar.getContactIconView().setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            new ContactResourceSwitcher().showResources(getActivity(), visavis);
        }
    });

    return v;
}

From source file:org.chromium.chrome.browser.widget.findinpage.FindToolbar.java

@Override
public void onFinishInflate() {
    super.onFinishInflate();

    setOrientation(HORIZONTAL);/*from   w w  w.j  av a2  s . c  o m*/
    setGravity(Gravity.CENTER_VERTICAL);

    mFindQuery = (FindQuery) findViewById(R.id.find_query);
    mFindQuery.setFindToolbar(this);
    mFindQuery.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_FILTER);
    mFindQuery.setSelectAllOnFocus(true);
    mFindQuery.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            mAccessibilityDidActivateResult = false;
            if (!hasFocus) {
                if (mFindQuery.getText().length() > 0) {
                    mSearchKeyShouldTriggerSearch = true;
                }
                UiUtils.hideKeyboard(mFindQuery);
            }
        }
    });
    mFindQuery.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (mFindInPageBridge == null)
                return;

            mAccessibilityDidActivateResult = false;
            setPrevNextEnabled(s.length() > 0);

            if (mSettingFindTextProgrammatically)
                return;

            // If we're called during onRestoreInstanceState() the current
            // view won't have been set yet. TODO(husky): Find a better fix.
            assert mCurrentTab != null;
            assert mCurrentTab.getContentViewCore() != null;
            if (mCurrentTab.getContentViewCore() == null)
                return;

            if (s.length() > 0) {
                // Don't clearResults() as that would cause flicker.
                // Just wait until onFindResultReceived updates it.
                mSearchKeyShouldTriggerSearch = false;
                mFindInPageBridge.startFinding(s.toString(), true, false);
            } else {
                clearResults();
                mFindInPageBridge.stopFinding(true);
            }

            if (!mCurrentTab.isIncognito()) {
                mLastUserSearch = s.toString();
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    mFindQuery.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null && event.getAction() == KeyEvent.ACTION_UP)
                return false;

            if (mFindInPageBridge == null)
                return false;

            // Only trigger a new find if the text was set programmatically.
            // Otherwise just revisit the current active match.
            if (mSearchKeyShouldTriggerSearch) {
                mSearchKeyShouldTriggerSearch = false;
                hideKeyboardAndStartFinding(true);
            } else {
                UiUtils.hideKeyboard(mFindQuery);
                mFindInPageBridge.activateFindInPageResultForAccessibility();
                mAccessibilityDidActivateResult = true;
            }
            return true;
        }
    });

    mFindStatus = (TextView) findViewById(R.id.find_status);

    mFindPrevButton = (TintedImageButton) findViewById(R.id.find_prev_button);
    mFindPrevButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            hideKeyboardAndStartFinding(false);
        }
    });

    mFindNextButton = (TintedImageButton) findViewById(R.id.find_next_button);
    mFindNextButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            hideKeyboardAndStartFinding(true);
        }
    });

    setPrevNextEnabled(false);

    mCloseFindButton = (TintedImageButton) findViewById(R.id.close_find_button);
    mCloseFindButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            deactivate();
        }
    });
}

From source file:com.anjalimacwan.MainActivity.java

@Override
public boolean dispatchKeyShortcutEvent(KeyEvent event) {
    super.dispatchKeyShortcutEvent(event);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.isCtrlPressed()) {
            if (getSupportFragmentManager().findFragmentById(R.id.noteViewEdit) instanceof NoteListFragment) {
                NoteListFragment fragment = (NoteListFragment) getSupportFragmentManager()
                        .findFragmentByTag("NoteListFragment");
                fragment.dispatchKeyShortcutEvent(event.getKeyCode());
            } else if (getSupportFragmentManager()
                    .findFragmentById(R.id.noteViewEdit) instanceof NoteViewFragment) {
                NoteViewFragment fragment = (NoteViewFragment) getSupportFragmentManager()
                        .findFragmentByTag("NoteViewFragment");
                fragment.dispatchKeyShortcutEvent(event.getKeyCode());
            } else if (getSupportFragmentManager()
                    .findFragmentById(R.id.noteViewEdit) instanceof NoteEditFragment) {
                NoteEditFragment fragment = (NoteEditFragment) getSupportFragmentManager()
                        .findFragmentByTag("NoteEditFragment");
                fragment.dispatchKeyShortcutEvent(event.getKeyCode());
            } else if (getSupportFragmentManager()
                    .findFragmentById(R.id.noteViewEdit) instanceof WelcomeFragment) {
                WelcomeFragment fragment = (WelcomeFragment) getSupportFragmentManager()
                        .findFragmentByTag("NoteListFragment");
                fragment.dispatchKeyShortcutEvent(event.getKeyCode());
            }/* w w  w .j  a v  a 2  s. c o m*/

            return true;
        }
    }
    return super.dispatchKeyShortcutEvent(event);
}