Example usage for android.view KeyEvent KEYCODE_DPAD_CENTER

List of usage examples for android.view KeyEvent KEYCODE_DPAD_CENTER

Introduction

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

Prototype

int KEYCODE_DPAD_CENTER

To view the source code for android.view KeyEvent KEYCODE_DPAD_CENTER.

Click Source Link

Document

Key code constant: Directional Pad Center key.

Usage

From source file:com.android.calculator2.EventListener.java

@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
    int action = keyEvent.getAction();

    // Work-around for spurious key event from IME, bug #1639445
    if (action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
        return true; // eat it
    }//from   ww  w.jav a2  s  .  co m

    if (keyEvent.getUnicodeChar() == '=') {
        if (action == KeyEvent.ACTION_UP) {
            mHandler.onEnter();
        }
        return true;
    }

    if (keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP
            && keyCode != KeyEvent.KEYCODE_DPAD_DOWN && keyCode != KeyEvent.KEYCODE_ENTER) {
        if (keyEvent.isPrintingKey() && action == KeyEvent.ACTION_UP) {
            // Tell the handler that text was updated.
            mHandler.onTextChanged();
        }
        return false;
    }

    /*
     * We should act on KeyEvent.ACTION_DOWN, but strangely sometimes the
     * DOWN event isn't received, only the UP. So the workaround is to act
     * on UP... http://b/issue?id=1022478
     */

    if (action == KeyEvent.ACTION_UP) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            mHandler.onEnter();
            break;

        case KeyEvent.KEYCODE_DPAD_UP:
            mHandler.onUp();
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            mHandler.onDown();
            break;
        }
    }
    return true;
}

From source file:it.chefacile.app.MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mContext = this;
    chefacileDb = new DatabaseHelper(this);
    // FilterButton = (ImageButton) findViewById(R.id.buttonfilter);
    TutorialButton = (ImageButton) findViewById(R.id.button);
    //  AddButton = (ImageButton) findViewById(R.id.button2);
    responseView = (TextView) findViewById(R.id.responseView);
    editText = (EditText) findViewById(R.id.ingredientText);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    //Show = (ImageButton) findViewById(R.id.buttonShow);
    //Show2 = (ImageButton) findViewById(R.id.buttonShow2);
    materialAnimatedSwitch = (MaterialAnimatedSwitch) findViewById(R.id.pin);
    //buttoncuisine = (ImageButton) findViewById(R.id.btn_cuisine);
    //buttondiet = (ImageButton) findViewById(R.id.btn_diet);
    //buttonintol = (ImageButton) findViewById(R.id.btn_intoll);
    //Mostra = (Button) findViewById(R.id.btn_mostra);

    final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    animation.setDuration(1000); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(5); // Repeat animation infinitely
    animation.setRepeatMode(Animation.REVERSE);

    ImageView icon = new ImageView(this); // Create an icon
    icon.setImageDrawable(getResources().getDrawable(R.drawable.logo));

    final com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton actionButton = new com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.Builder(
            this).setPosition(
                    com.oguzdev.circularfloatingactionmenu.library.FloatingActionButton.POSITION_RIGHT_CENTER)
                    .setContentView(icon).build();

    SubActionButton.Builder itemBuilder = new SubActionButton.Builder(this);
    // repeat many times:
    ImageView dietIcon = new ImageView(this);
    dietIcon.setImageDrawable(getResources().getDrawable(R.drawable.diet));
    SubActionButton button1 = itemBuilder.setContentView(dietIcon).build();
    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showSingleChoiceDialogDiet(v);
        }/*  w  w  w .  j  ava2 s .  com*/
    });

    ImageView intolIcon = new ImageView(this);
    intolIcon.setImageDrawable(getResources().getDrawable(R.drawable.intoll));
    SubActionButton button2 = itemBuilder.setContentView(intolIcon).build();
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showMultiChoiceDialogIntol(v);
        }
    });

    ImageView cuisineIcon = new ImageView(this);
    cuisineIcon.setImageDrawable(getResources().getDrawable(R.drawable.cook12));
    SubActionButton button3 = itemBuilder.setContentView(cuisineIcon).build();
    button3.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showMultiChoiceDialogCuisine(v);
        }
    });

    ImageView favouriteIcon = new ImageView(this);
    favouriteIcon.setImageDrawable(getResources().getDrawable(R.drawable.favorite));
    SubActionButton button4 = itemBuilder.setContentView(favouriteIcon).build();
    button4.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showSimpleListDialogFav(v);
        }
    });

    ImageView wandIcon = new ImageView(this);
    wandIcon.setImageDrawable(getResources().getDrawable(R.drawable.wand));
    SubActionButton button5 = itemBuilder.setContentView(wandIcon).build();
    button5.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            sugg = getSuggestion();
            suggOccurrences = getCount();
            showSimpleListDialogSuggestions(v);
        }
    });

    final FloatingActionButton actionABC = (FloatingActionButton) findViewById(R.id.action_abc);

    actionABC.bringToFront();
    actionABC.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (ingredients.length() < 2) {
                Snackbar.make(responseView, "Insert at least one ingredient", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            } else {
                new RetrieveFeedTask().execute();
            }
        }

        // Snackbar.make(view, "Non disponibile, mangia l'aria", Snackbar.LENGTH_LONG)
        //         .setAction("Action", null).show();

    });

    FloatingActionMenu actionMenu = new FloatingActionMenu.Builder(this).setStartAngle(90).setEndAngle(270)
            .addSubActionView(button1).addSubActionView(button2).addSubActionView(button3)
            .addSubActionView(button4).addSubActionView(button5).attachTo(actionButton).build();

    startDatabase(chefacileDb);

    for (int j = 0; j < cuisineItems.length; j++) {
        cuisineItems[j] = cuisineItems[j].substring(0, 1).toUpperCase() + cuisineItems[j].substring(1);
    }
    Arrays.sort(cuisineItems);

    for (int i = 0; i < 24; i++) {
        cuisineBool[i] = false;
    }

    Arrays.sort(intolItems);

    for (int i = 0; i < 11; i++) {
        intolBool[i] = false;
    }

    mListView = (MaterialListView) findViewById(R.id.material_listview);

    adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);

    TutorialButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, IntroScreenActivity.class));
            overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

        }
    });

    iv = (ImageView) findViewById(R.id.imageView);
    iv.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            clicks++;
            Log.d("CLICKS", String.valueOf(clicks));
            if (clicks == 15) {
                Log.d("IMAGE SHOWN", "mai vero");
                setBackground(iv);
            }
        }
    });

    materialAnimatedSwitch.setOnCheckedChangeListener(new MaterialAnimatedSwitch.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(boolean isChecked) {
            if (isChecked == true) {
                ranking = 2;
                Toast.makeText(getApplicationContext(), "Minimize missing ingredients", Toast.LENGTH_SHORT)
                        .show();
            } else {
                ranking = 1;
                Toast.makeText(getApplicationContext(), "Maximize used ingredients", Toast.LENGTH_SHORT).show();
            }
            Log.d("Ranking", String.valueOf(ranking));
        }
    });

    final CharSequence[] items = { "Maximize used ingredients", "Minimize missing ingredients" };

    editText.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    if (!(editText.getText().toString().trim().equals(""))) {

                        String input;
                        String s1 = editText.getText().toString().substring(0, 1).toUpperCase();
                        String s2 = editText.getText().toString().substring(1);
                        input = s1 + s2;

                        Log.d("INPUT: ", input);
                        searchedIngredients.add(input);
                        Log.d("SEARCHED INGR LIST", searchedIngredients.toString());

                        if (!chefacileDb.findIngredientPREF(input)) {
                            if (chefacileDb.findIngredient(input)) {
                                chefacileDb.updateCount(input);
                                mapIngredients = chefacileDb.getDataInMapIngredient();
                                Map<String, Integer> map2;
                                map2 = sortByValue(mapIngredients);
                                Log.d("MAPPACOUNT: ", map2.toString());

                            } else {
                                if (chefacileDb.occursExceeded()) {
                                    //chefacileDb.deleteMinimum(input);
                                    // chefacileDb.insertDataIngredient(input);
                                    mapIngredients = chefacileDb.getDataInMapIngredient();
                                    Map<String, Integer> map3;
                                    map3 = sortByValue(mapIngredients);
                                    Log.d("MAPPAINGREDIENTE: ", map3.toString());

                                } else {
                                    chefacileDb.insertDataIngredient(input);
                                    mapIngredients = chefacileDb.getDataInMapIngredient();
                                    Map<String, Integer> map3;
                                    map3 = sortByValue(mapIngredients);
                                    Log.d("MAPPAINGREDIENTE: ", map3.toString());
                                }
                            }
                        }
                    }

                    if (editText.getText().toString().trim().equals("")) {
                        ingredients += editText.getText().toString().trim() + "";
                        editText.getText().clear();

                    } else {
                        ingredients += editText.getText().toString().replaceAll(" ", "+").trim().toLowerCase()
                                + ",";
                        singleIngredient = editText.getText().toString().trim().toLowerCase();
                        currentIngredient = singleIngredient;
                        new RetrieveIngredientTask().execute();

                        //adapter.add(singleIngredient.substring(0,1).toUpperCase() + singleIngredient.substring(1));
                    }

                    InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

                    in.hideSoftInputFromWindow(editText.getApplicationWindowToken(),
                            InputMethodManager.HIDE_NOT_ALWAYS);

                    actionABC.startAnimation(animation);

                    return true;
                default:
                    break;
                }
            }
            return false;
        }
    });

    responseView = (TextView) findViewById(R.id.responseView);
    editText = (EditText) findViewById(R.id.ingredientText);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);

}

From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java

private static boolean isReadable(int keyCode, KeyEvent event) {
    if (KeyEvent.isModifierKey(keyCode) || event.isSystem()) {
        return false;
    }//from   www  .ja va2  s . c  o m

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_ENTER:
        return false;
    }

    return true;
}

From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java

@Override
public boolean onBgListViewKeyDown(BgListView bgListView, int keyCode, KeyEvent event) {
    int p;/*from  w w w .  j  av a 2s  . co  m*/
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (btnSearch.getVisibility() == View.VISIBLE)
            btnSearch.requestFocus();
        else
            btnGoBack.requestFocus();
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        btnGoBackToPlayer.requestFocus();
        return true;
    case KeyEvent.KEYCODE_ENTER:
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_0:
    case KeyEvent.KEYCODE_SPACE:
        p = radioStationList.getSelection();
        if (p >= 0)
            processItemClick(p);
        return true;
    }
    return false;
}

From source file:org.mozilla.gecko.AwesomeBar.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // This method is called only if the key event was not handled
    // by any of the views, which usually means the edit box lost focus
    if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU
            || keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_DPAD_UP
            || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_LEFT
            || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_CENTER
            || keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_VOLUME_UP
            || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
        return super.onKeyDown(keyCode, event);
    } else {//from  ww w  .j a  v a2s.  c om
        int selStart = -1;
        int selEnd = -1;
        if (mText.hasSelection()) {
            selStart = mText.getSelectionStart();
            selEnd = mText.getSelectionEnd();
        }

        // Return focus to the edit box, and dispatch the event to it
        mText.requestFocusFromTouch();

        if (selStart >= 0) {
            // Restore the selection, which gets lost due to the focus switch
            mText.setSelection(selStart, selEnd);
        }

        mText.dispatchKeyEvent(event);
        return true;
    }
}

From source file:org.yammp.app.MusicPlaybackActivity.java

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

    int repcnt = event.getRepeatCount();

    switch (keyCode) {

    case KeyEvent.KEYCODE_DPAD_LEFT:
        if (!useDpadMusicControl()) {
            break;
        }/*from   w w w.ja  v  a 2s .  co  m*/
        if (!mPrevButton.hasFocus()) {
            mPrevButton.requestFocus();
        }
        scanBackward(repcnt, event.getEventTime() - event.getDownTime());
        return true;
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        if (!useDpadMusicControl()) {
            break;
        }
        if (!mNextButton.hasFocus()) {
            mNextButton.requestFocus();
        }
        scanForward(repcnt, event.getEventTime() - event.getDownTime());
        return true;

    // case KeyEvent.KEYCODE_R:
    // toggleRepeat();
    // return true;
    //
    // case KeyEvent.KEYCODE_S:
    // toggleShuffle();
    // return true;

    case KeyEvent.KEYCODE_N:
        if (mService != null) {
            try {
                mService.next();
                return true;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        } else
            return false;

    case KeyEvent.KEYCODE_P:
        if (mService != null) {
            try {
                mService.prev();
                return true;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        } else
            return false;

    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_SPACE:
        doPauseResume();
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

From source file:android.support.v17.leanback.app.PlaybackSupportFragment.java

private boolean onInterceptInputEvent(InputEvent event) {
    final boolean controlsHidden = !mControlVisible;
    if (DEBUG)/*from   w  w w. j ava  2 s .  co m*/
        Log.v(TAG, "onInterceptInputEvent hidden " + controlsHidden + " " + event);
    boolean consumeEvent = false;
    int keyCode = KeyEvent.KEYCODE_UNKNOWN;
    int keyAction = 0;

    if (event instanceof KeyEvent) {
        keyCode = ((KeyEvent) event).getKeyCode();
        keyAction = ((KeyEvent) event).getAction();
        if (mInputEventHandler != null) {
            consumeEvent = mInputEventHandler.onKey(getView(), keyCode, (KeyEvent) event);
        }
    }

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
        // Event may be consumed; regardless, if controls are hidden then these keys will
        // bring up the controls.
        if (controlsHidden) {
            consumeEvent = true;
        }
        if (keyAction == KeyEvent.ACTION_DOWN) {
            tickle();
        }
        break;
    case KeyEvent.KEYCODE_BACK:
    case KeyEvent.KEYCODE_ESCAPE:
        if (mInSeek) {
            // when in seek, the SeekUi will handle the BACK.
            return false;
        }
        // If controls are not hidden, back will be consumed to fade
        // them out (even if the key was consumed by the handler).
        if (!controlsHidden) {
            consumeEvent = true;

            if (((KeyEvent) event).getAction() == KeyEvent.ACTION_UP) {
                hideControlsOverlay(true);
            }
        }
        break;
    default:
        if (consumeEvent) {
            if (keyAction == KeyEvent.ACTION_DOWN) {
                tickle();
            }
        }
    }
    return consumeEvent;
}

From source file:org.telegram.ui.Components.NumberPicker.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final int keyCode = event.getKeyCode();
    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_ENTER:
        removeAllCallbacks();/*  ww  w  .  j  a  v a 2 s  . c  o  m*/
        break;
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_DPAD_UP:
        switch (event.getAction()) {
        case KeyEvent.ACTION_DOWN:
            if (mWrapSelectorWheel || (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) ? getValue() < getMaxValue()
                    : getValue() > getMinValue()) {
                requestFocus();
                mLastHandledDownDpadKeyCode = keyCode;
                removeAllCallbacks();
                if (mFlingScroller.isFinished()) {
                    changeValueByOne(keyCode == KeyEvent.KEYCODE_DPAD_DOWN);
                }
                return true;
            }
            break;
        case KeyEvent.ACTION_UP:
            if (mLastHandledDownDpadKeyCode == keyCode) {
                mLastHandledDownDpadKeyCode = -1;
                return true;
            }
            break;
        }
    }
    return super.dispatchKeyEvent(event);
}

From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_results_resource);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    Bundle extra = getIntent().getExtras();

    if (extra != null) {
        searchKeyword = extra.getString("keyWord").trim();
    }//w  w w. j  a  v  a  2 s .  c o  m
    prefsPrivate = getSharedPreferences(PREFS_PRIVATE, Context.MODE_PRIVATE);

    token = prefsPrivate.getString("token", "");

    imageViewClose = (ImageView) findViewById(R.id.imageViewClose);
    imageViewSearch = (ImageView) findViewById(R.id.imageViewSearch);
    editTextSearchResults = (EditText) findViewById(R.id.textViewSearch);
    switchResColl = (Switch) findViewById(R.id.switchResColl);
    dialog1 = new Dialog(this);
    editTextSearchResults.setText(searchKeyword);
    imm = (InputMethodManager) this.getSystemService(Service.INPUT_METHOD_SERVICE);
    dialog = new ProgressDialog(this);
    dialog.setTitle("gooru");
    dialog.setMessage("Please wait while loading...");
    dialog.setCancelable(false);
    dialog.show();

    if (checkInternetConnection()) {
        new getResources().execute();
    } else {
        showDialog("Please Check Internet connection");
        new getResources().execute();
    }

    // scroll views

    videoScroll = (HorizontalScrollView) findViewById(R.id.videoScroll);
    interactiveScroll = (HorizontalScrollView) findViewById(R.id.interactiveScroll);
    websiteScroll = (HorizontalScrollView) findViewById(R.id.websiteScroll);
    textbookScroll = (HorizontalScrollView) findViewById(R.id.textbookScroll);
    examScroll = (HorizontalScrollView) findViewById(R.id.examScroll);
    handoutScroll = (HorizontalScrollView) findViewById(R.id.handoutScroll);
    slideScroll = (HorizontalScrollView) findViewById(R.id.slideScroll);
    lessonScroll = (HorizontalScrollView) findViewById(R.id.lessonScroll);
    // category image load more resources
    videoRight = (ImageView) findViewById(R.id.videoRight);
    interactiveRight = (ImageView) findViewById(R.id.interactiveRight);
    websiteRight = (ImageView) findViewById(R.id.websiteRight);
    textbookRight = (ImageView) findViewById(R.id.textbookRight);
    examRight = (ImageView) findViewById(R.id.examRight);
    handoutRight = (ImageView) findViewById(R.id.handoutRight);
    slideRight = (ImageView) findViewById(R.id.slideRight);
    lessonRight = (ImageView) findViewById(R.id.lessonRight);

    videoRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                videoCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5Videos().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    interactiveRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                interactiveCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5interactive().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });

    imageViewSearch.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            String searchKeyword = editTextSearchResults.getText().toString().trim();

            if (searchKeyword.length() > 0) {

                Intent intentResResults = new Intent(getBaseContext(), SearchResults_resource.class);
                searchKeyword = editTextSearchResults.getText().toString().trim();
                Log.i("Search :", searchKeyword);
                Bundle extras = new Bundle();
                extras.putString("keyWord", searchKeyword);
                intentResResults.putExtras(extras);
                startActivity(intentResResults);
                finish();

            } else {
                dialog1.setTitle("Please enter a Search keyword");
                dialog1.show();
            }
        }
    });

    websiteRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                websiteCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5website().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    textbookRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                textbookCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5textbook().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    examRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                examCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5exam().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    handoutRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                handoutCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5handout().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    slideRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                slideCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5slide().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });
    lessonRight.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            if (checkInternetConnection()) {
                lessonCount++;
                dialog.setTitle("gooru");
                dialog.setMessage("Please wait while loading...");
                dialog.setCancelable(false);
                dialog.show();
                new getNext5lesson().execute();
            } else {
                showDialog("Please Check Internet connection");
            }

        }
    });

    editTextSearchResults.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
                switch (keyCode) {
                case KeyEvent.KEYCODE_DPAD_CENTER:
                case KeyEvent.KEYCODE_ENTER:
                    String searchKeyword = editTextSearchResults.getText().toString().trim();

                    if (searchKeyword.length() > 0) {

                        Log.i("Resources", searchKeyword);
                        Intent intentResResults = new Intent(getBaseContext(), SearchResults_resource.class);

                        Bundle extras = new Bundle();
                        extras.putString("keyWord", searchKeyword);

                        intentResResults.putExtras(extras);
                        startActivity(intentResResults);
                        finish();
                    } else {
                        dialog1.setTitle("Please enter a Search keyword");
                        dialog1.show();
                    }
                    return true;
                default:
                    break;
                }
            }
            return false;
        }
    });

    imageViewClose.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            finish();
        }
    });

}

From source file:org.medcare.Dicom.DicomActivity.java

public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.e(TAG, "onKeyDown!!!!!!!!!!!!!!! " + keyCode);
    if (keyCode == KeyEvent.KEYCODE_PLUS) {
        Log.e(TAG, "zoomIn!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomIn");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_MINUS) {
        Log.e(TAG, "zoomOut!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomOut");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
        Log.e(TAG, "zoomIn!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomIn");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
        Log.e(TAG, "zoomOut!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("zoomOut");
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER) {
        Log.e(TAG, "Del!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("Del");
    } else if (keyCode == KeyEvent.KEYCODE_DEL) {
        Log.e(TAG, "del!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("Del");
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
        Log.e(TAG, "TAGS_INFO!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("TAGS_INFO");
    } else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
        Log.e(TAG, "TAGS_OFF!!!!!!!!!!!!!!!");
        this.dicomView.dicomThread.action("TAGS_OFF");
    }/*w  w w  .  j a  va  2 s .  co  m*/
    return false;
}