Java Code Examples for android.view.MenuItem

The following are top voted examples for showing how to use android.view.MenuItem. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: yaacc-code   File: MultiContentPlayerActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_settings:
            Intent i = new Intent(this, SettingsActivity.class);
            startActivity(i);
            return true;
        case R.id.yaacc_about:
            AboutActivity.showAbout(this);
            return true;
        case R.id.yaacc_log:
            YaaccLogActivity.showLog(this);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 2
Project: yaacc-code   File: ThirdPartieMusicPlayerActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_settings:
            Intent i = new Intent(this, SettingsActivity.class);
            startActivity(i);
            return true;
        case R.id.yaacc_about:
            AboutActivity.showAbout(this);
            return true;
        case R.id.yaacc_log:
            YaaccLogActivity.showLog(this);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 3
Project: Quran   File: AyahToolBar.java   View source code 6 votes vote down vote up
private void showMenu(Menu menu) {
  if (currentMenu == menu) {
    // no need to re-draw
    return;
  }

  menuLayout.removeAllViews();
  final int count = menu.size();
  for (int i=0; i<count; i++) {
    final MenuItem item = menu.getItem(i);
    if (item.isVisible()) {
      final View view = getMenuItemView(item);
      menuLayout.addView(view);
    }
  }

  currentMenu = menu;
}
 
Example 4
Project: Protestr   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_logout:
            Prefs.with(this).clear();
            startActivity(new Intent(this, LoginActivity.class));
            overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
            finish();
            return true;
        case R.id.action_settings:
            startActivity(new Intent(this, SettingsActivity.class));
            overridePendingTransition(R.anim.activity_in, R.anim.activity_out);
            return true;
        default:
            return false;
    }
}
 
Example 5
Project: BizareChat   File: UsersFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.users_action_filter:
            sortItem.collapseActionView();
            item.expandActionView();
            return true;
        case R.id.users_action_sort:
            filterItem.collapseActionView();
            item.expandActionView();
            return true;
        case R.id.filter_default:
            presenter.sortDefault();
            sortItem.collapseActionView();
            return true;
        case R.id.filter_name_asc:
            presenter.sortByNameAsc();
            sortItem.collapseActionView();
            return true;
        case R.id.filter_name_desc:
            presenter.sortByNameDesc();
            sortItem.collapseActionView();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 6
Project: WarningSystemWeather-Android-App   File: ListFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case R.id.refresh_main:
            if (isNetworkAvailable()) {
                grabData();
            }
            break;
        case R.id.more_apps:
            moreApps();
            break;
        default:
    }
    return super.onOptionsItemSelected(item);
}
 
Example 7
Project: Mixtape   File: RecyclerBodyView.java   View source code 6 votes vote down vote up
/**
 * Shows a contextual popup menu anchored to the supplied view. Item selections are passed to
 * the presenter.
 *
 * @param anchor
 * 		the view to anchor the menu to, not null
 * @param item
 * 		the LibraryItem associated with the contextual menu, not null
 */
private void showMenu(final View anchor, final LibraryItem item) {
	checkNotNull(item, "item cannot be null.");
	checkNotNull(anchor, "overflowButton cannot be null.");

	final PopupMenu menu = new PopupMenu(getContext(), anchor);
	menu.inflate(contextualMenuResourceId);
	menu.show();

	// Propagate menu selections back to the presenter
	menu.setOnMenuItemClickListener(new OnMenuItemClickListener() {
		@Override
		public boolean onMenuItemClick(final MenuItem menuItem) {
			for (final MenuItemSelectedListener listener : menuItemSelectedListeners) {
				listener.onContextualMenuItemSelected(RecyclerBodyView.this, item, menuItem);
			}

			return true;
		}
	});
}
 
Example 8
Project: SmoothRefreshLayout   File: TestNestedHorizontalViewsActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            onBackPressed();
            return true;
        case Menu.FIRST:
            if (mRefreshLayout.isEnableCheckFingerInsideAnotherDirectionView()) {
                mRefreshLayout.setEnableCheckFingerInsideAnotherDirectionView(false);
                item.setTitle(R.string.enable_check_finger_inside_horizontal_view);
            } else {
                mRefreshLayout.setEnableCheckFingerInsideAnotherDirectionView(true);
                item.setTitle(R.string.disable_check_finger_inside_horizontal_view);
            }
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 9
Project: app-android   File: MainActivity.java   View source code 6 votes vote down vote up
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_lsf) {
        NavigationController.getInstance().navigateToLSF();
    } else if (id == R.id.nav_canteen) {
        NavigationController.getInstance().navigateToCanteen();
    } else if (id == R.id.nav_settings) {
        NavigationController.getInstance().navigateToSettings();
    }  else if (id == R.id.nav_test) {
        startActivity(new Intent(this, VmTestActivity.class));
    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
Example 10
Project: CoordinatorTabLayout   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();
    }

    switch (item.getItemId()) {
        case R.id.action_about:
            IntentUtils.openUrl(this, "https://github.com/hugeterry/CoordinatorTabLayout");
            break;
        case R.id.action_about_me:
            IntentUtils.openUrl(this, "http://hugeterry.cn/about");
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 11
Project: edslider   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    switch (item.getItemId()){
        case R.id.changeview:
            if (recyclerView.getVisibility() == View.VISIBLE)
            {
                recyclerView.setVisibility(View.GONE);
                layoutTest.setVisibility(View.VISIBLE);
            }
            else
            {
                recyclerView.setVisibility(View.VISIBLE);
                layoutTest.setVisibility(View.GONE);
            }
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 12
Project: aos-Video   File: BrowserAllTvShows.java   View source code 6 votes vote down vote up
@Override
public boolean onContextItemSelected(MenuItem item) {
	if(item.getItemId() ==  R.string.copy_on_device_multi){
		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
		Tvshow tvshow = (Tvshow) mBrowserAdapter.getItem(info.position);
		ArrayList<Uri> list = new ArrayList<>();
		Cursor cursor2 = getEpisodeForShowCursor(tvshow.getTvshowId());
		if(cursor2!=null) {
			if (cursor2.getCount() > 0) {
				cursor2.moveToFirst();
				int uriCol = cursor2.getColumnIndex(VideoStore.MediaColumns.DATA);
				do {
					Uri uri = Uri.parse(cursor2.getString(uriCol));
					if (!Utils.isLocal(uri))
						list.add(uri);
				} while (cursor2.moveToNext());
				startDownloadingVideo(list);

			}
		}
		cursor2.close();
		return  true;
	}
	else return super.onContextItemSelected(item);

}
 
Example 13
Project: FantaF1   File: MainActivity.java   View source code 6 votes vote down vote up
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.n_home) {
        setFragment(new Tab0Home(), getString(R.string.td_main),"");
    } else if (id == R.id.n_news) {
        setFragment(new TabBrowser(), getString(R.string.td_news),"");
    } else if (id == R.id.n_drivers) {
        setFragment(new Tab2Drivers(), getString(R.string.td_drivers),"");
    } else if (id == R.id.n_stats) {
        setFragment(new Tab3Stats(), getString(R.string.td_stats),"");
    } else if (id == R.id.n_guide) {
        setFragment(new TabBrowser(), getString(R.string.td_guide), getString(R.string.link_guide));
    } else if (id == R.id.n_rules) {
        setFragment(new TabBrowser(), getString(R.string.td_rules), getString(R.string.link_rules));
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
Example 14
Project: Remindy   File: PlaceActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {

        // Respond to the mToolbar's back/home button
        case android.R.id.home:
            onBackPressed();
            return true;

        case R.id.menu_place_save:
            handleSaveOrUpdatePlace();
            break;

        case R.id.menu_place_delete:
            handleDeletePlace();
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 15
Project: JKCloud   File: OpportunityListActivity.java   View source code 6 votes vote down vote up
@Override
protected void initViewListener() {
    super.initViewListener();
    fabSpeed.setMenuListener(new SimpleMenuListenerAdapter() {

        @Override
        public boolean onMenuItemSelected(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
                case R.id.action_new:
                    startActivityForResult(new Intent(OpportunityListActivity.this,
                            NewOpportunityActivity.class), ACTION_NEW);
                    break;
                case R.id.action_search:
                    startActivityForResult(new Intent(OpportunityListActivity.this,
                            SearchActivity.class), ACTION_SEARCH);
                    break;
            }
            return super.onMenuItemSelected(menuItem);
        }
    });
}
 
Example 16
Project: YZxing   File: ScannerActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    if (itemId == R.id.scan_from_picture) {
        //先申请权限
        int checked = ContextCompat.checkSelfPermission(ScannerActivity.this
                , Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if (checked == PackageManager.PERMISSION_GRANTED) {
            goPicture();
        } else {
            ActivityCompat.requestPermissions(ScannerActivity.this
                    , new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE_WRITE_EXTERNAL_STORAGE);
        }
    }
    return true;
}
 
Example 17
Project: Android-DFU-App   File: DfuActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
	switch (item.getItemId()) {
		case android.R.id.home:
			onBackPressed();
			break;
		case R.id.action_about:
			final AppHelpFragment fragment = AppHelpFragment.getInstance(R.string.dfu_about_text);
			fragment.show(getSupportFragmentManager(), "help_fragment");
			break;
		case R.id.action_settings:
			final Intent intent = new Intent(this, SettingsActivity.class);
			startActivity(intent);
			break;
	}
	return true;
}
 
Example 18
Project: diycode   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        openActivity(SettingActivity.class);
        return true;
    } else if (id == R.id.action_notification) {
        if (!mDiycode.isLogin()) {
            openActivity(LoginActivity.class);
        } else {
            openActivity(NotificationActivity.class);
        }
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 19
Project: mobile-grammar   File: WebViewActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.create_reminder_menu_item) {
        Intent intent = new Intent();

        // mimeType will popup the chooser any  for any implementing application (e.g. the built in calendar or applications such as "Business calendar"
        intent.setType("vnd.android.cursor.item/event");

        // the time the event should start in millis. This example uses now as the start time and ends in 1 hour
        intent.putExtra("beginTime", new Date().getTime());
        intent.putExtra("endTime", new Date().getTime() + DateUtils.HOUR_IN_MILLIS);

        intent.putExtra("title", getString(R.string.text_reminder_about_lesson));
        intent.putExtra("description", getString(R.string.text_reminder_about_lesson) + ":" + lessonName);

        // the action
        intent.setAction(Intent.ACTION_EDIT);
        startActivity(intent);
    }

    return super.onOptionsItemSelected(item);
}
 
Example 20
Project: emptyview   File: SampleActivity.java   View source code 6 votes vote down vote up
@Override public boolean onOptionsItemSelected(MenuItem item) {
    int itemId = item.getItemId();
    switch (itemId) {
        case R.id.show_progress:
            emptyPresenter.showLoading();
            break;
        case R.id.show_content:
            emptyPresenter.showContent();
            break;
        case R.id.show_error:
            emptyPresenter.showError();
            break;
        case R.id.show_empty:
            emptyPresenter.showEmpty();
            break;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 21
Project: Recognize-it   File: CameraActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case android.R.id.home: {
            finish();
            break;
        }
        case R.id.menu_image_capture: {
            takePicture();
            break;
        }
        case R.id.menu_video_capture: {
            recordVideo();
            break;
        }
    }
    return true;
}
 
Example 22
Project: GitHub   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    IBoxingMediaLoader loader;
    switch (id) {
        case R.id.menu_fresco:
            loader = new BoxingFrescoLoader(this);
            break;
        case R.id.menu_glide:
            loader = new BoxingGlideLoader();
            break;
        case R.id.menu_picasso:
            loader = new BoxingPicassoLoader();
            break;
        default:
            loader = new BoxingFrescoLoader(this);
            break;
    }
    BoxingMediaLoader.getInstance().init(loader);
    return super.onOptionsItemSelected(item);
}
 
Example 23
Project: BittrexApi   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final int itemId = item.getItemId();

    switch (itemId) {
        case R.id.action_authentication:
            AuthenticationActivity.startActivity(this);

            return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 24
Project: AppsTimeline   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.refresh:
            mAdapter.clear();
            process();
            return true;
        case R.id.settings:
            startActivityForResult(new Intent(MainActivity.this, SettingsActivity.class), 1);
            return true;
        case R.id.sort:
            if (DataManager.getInstance().hasPermission(getApplicationContext())) {
                mDialog = new AlertDialog.Builder(this)
                        .setTitle(R.string.sort)
                        .setSingleChoiceItems(R.array.sort, PreferenceManager.getInstance().getInt(PreferenceManager.PREF_LIST_SORT), new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                PreferenceManager.getInstance().putInt(PreferenceManager.PREF_LIST_SORT, i);
                                process();
                                mDialog.dismiss();
                            }
                        })
                        .create();
                mDialog.show();
                return true;
            } else {
                return false;
            }
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 25
Project: DAPNETApp   File: MapFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item){
    item.setChecked(!item.isChecked());
    if (ewOverlay==null||dwOverlay==null||epOverlay==null||dpOverlay==null){
        config();
    }
    if(menu.getItem(2).isChecked()){
        ewOverlay.setEnabled(menu.getItem(0).isChecked());
        ewOverlay.setFocusItemsOnTap(menu.getItem(0).isChecked());

        dwOverlay.setEnabled(menu.getItem(1).isChecked());
        ewOverlay.setFocusItemsOnTap(menu.getItem(1).isChecked());
    }else {
        //Disable Online&&Offline WiderangeOverlay
        ewOverlay.setEnabled(false);
        ewOverlay.setFocusItemsOnTap(false);
        dwOverlay.setEnabled(false);
        dwOverlay.setFocusItemsOnTap(false);
    }
    if(menu.getItem(3).isChecked()){
        epOverlay.setEnabled(menu.getItem(0).isChecked());
        epOverlay.setFocusItemsOnTap(menu.getItem(0).isChecked());
        dpOverlay.setEnabled(menu.getItem(1).isChecked());
        epOverlay.setFocusItemsOnTap(menu.getItem(1).isChecked());
    }else {
        //Disable Online&&Offline PersOverlay
        epOverlay.setEnabled(false);
        epOverlay.setFocusItemsOnTap(false);
        dpOverlay.setEnabled(false);
        dpOverlay.setFocusItemsOnTap(false);
    }
    map.invalidate();
    InfoWindow.closeAllInfoWindowsOn(map);

    return true;

}
 
Example 26
Project: Todule-android   File: ToduleLabelFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.label_new:
            ToduleLabelAddFragment f = ToduleLabelAddFragment.newInstance(null);
            myActivity.getSupportFragmentManager().beginTransaction()
                    .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
                    .replace(R.id.fragment_container, f)
                    .addToBackStack(null)
                    .commit();
            return true;
        case R.id.label_confirm:
            mCallback.onLabelSelected(selectedLabelId);
            myActivity.onBackPressed();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 27
Project: boohee_v5.6   File: SportCourseActivity.java   View source code 5 votes vote down vote up
public boolean onOptionsItemSelected(MenuItem item) {
    if (WheelUtils.isFastDoubleClick()) {
        return true;
    }
    switch (item.getItemId()) {
        case R.id.action_download_manager:
            DownloadManageActivity.startActivity(this);
            return true;
        case R.id.action_course_history:
            MobclickAgent.onEvent(this.activity, Event.BINGO_VIEWCOURSEHISTORY);
            SportCourseHistoryActivity.comeOnBaby(this);
            return true;
        case R.id.action_change_course:
            MobclickAgent.onEvent(this.activity, Event.BINGO_CLICKCHANGECOURSE);
            SportCourseChangeActivity.comeOnBaby(this);
            return true;
        case R.id.action_change_reset:
            resetCourseDialog();
            return true;
        case R.id.action_course_introduce:
            MobclickAgent.onEvent(this.activity, Event.BINGO_VIEWCOURSEDOC);
            if (TextUtils.isEmpty(this.mIntroduceURL)) {
                return true;
            }
            BrowserActivity.comeOnBaby(this, "", this.mIntroduceURL);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 28
Project: MuslimMateAndroid   File: SelectPositionActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // app icon in action bar clicked; goto parent activity.
            this.finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 29
Project: TriMeshKit   File: MainSurfaceActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 30
Project: GitHub   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example 31
Project: FindX   File: Sign_up.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    switch (item.getItemId()) {



        case R.id.info: {
            AlertDialog.Builder alertadd = new AlertDialog.Builder(
                    Sign_up.this);
            LayoutInflater factory = LayoutInflater.from(Sign_up.this);

            final View view = factory.inflate(R.layout.dialog_main, null);

            ImageView image = (ImageView) view.findViewById(R.id.imageView);
            image.setImageResource(R.drawable.mylocation_help);

            alertadd.setView(view);


            alertadd.setPositiveButton("ok", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dlg, int sumthin) {

                }
            });
            alertDialog = alertadd.create();
            alertDialog.show();
            return super.onOptionsItemSelected(item);

        }

        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 32
Project: AndroidthingsStudy   File: Beam.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.menu_settings:
            Intent intent = new Intent(Settings.ACTION_NFCSHARING_SETTINGS);
            startActivity(intent);
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 33
Project: PopCorn   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);

    final MenuItem searchMenuItem = menu.findItem(R.id.action_search);
    final SearchView searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setQueryHint(getResources().getString(R.string.search_movies_tv_shows_people));

    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            if (!NetworkConnection.isConnected(MainActivity.this)) {
                Toast.makeText(MainActivity.this, R.string.no_network, Toast.LENGTH_SHORT).show();
                return true;
            }
            Intent intent = new Intent(MainActivity.this, SearchActivity.class);
            intent.putExtra(Constant.QUERY, query);
            startActivity(intent);
            searchMenuItem.collapseActionView();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });

    return true;
}
 
Example 34
Project: boohee_v5.6   File: CollectionActivity.java   View source code 5 votes vote down vote up
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case 1:
            if (getString(R.string.g6).equals(item.getTitle())) {
                item.setTitle(R.string.g7);
                this.mAdapter.setEdit(true);
                this.rippleLayout.setVisibility(8);
                this.viewOperate.setVisibility(0);
                this.viewOperate.startAnimation(AnimationUtils.loadAnimation(this, R.anim.o));
                return true;
            }
            item.setTitle(R.string.g6);
            this.mAdapter.setEdit(false);
            this.viewOperate.animate().alphaBy(1.0f).alpha(0.0f).setDuration(300).setListener
                    (new AnimatorListenerAdapter() {
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    CollectionActivity.this.viewOperate.setVisibility(8);
                    CollectionActivity.this.rippleLayout.setVisibility(0);
                    CollectionActivity.this.viewOperate.setAlpha(1.0f);
                }
            }).start();
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}
 
Example 35
Project: OSchina_resources_android   File: BrowserFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.public_menu_shared:
            showSharedDialog();
            break;
    }
    return true;
}
 
Example 36
Project: editor-sql   File: SqlCreateTableActivity.java   View source code 5 votes vote down vote up
@Override
    protected void initToolBar() {
        super.initToolBar();
        mToolbar.setSubtitle(getIntent().getStringExtra(DB_NAME));
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mNewColumnFieldList == null || mNewColumnFieldList.size() == 0) {
                    showExitTipDialog();
                } else {
                    finish();
                }
            }
        });
        mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {

                switch (item.getItemId()) {
                    case R.id.action_column_edit:
                        addColumnToTab(mNewColumnFieldList.get(mClickPosition), false);
                        break;

                    case R.id.action_column_delete:
//                        if (Utils.isFunNeedBuy(SqlCreateTableActivity.this)) {
//                            return true;
//                        }

                        showSureDeleteDialog();
                        break;

                }
                return true;
            }
        });
        initToolBarButton();
    }
 
Example 37
Project: buildAPKsSamples   File: Notepadv3.java   View source code 5 votes vote down vote up
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    switch(item.getItemId()) {
        case INSERT_ID:
            createNote();
            return true;
    }

    return super.onMenuItemSelected(featureId, item);
}
 
Example 38
Project: School1-Android   File: SchoolLoginActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home)
        onBackPressed();
    else
        return super.onOptionsItemSelected(item);

    return true;
}
 
Example 39
Project: USay   File: TouTiaoFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.xiandu:
            Intent intent = new Intent(getActivity(), WebViewXianDuActivity.class);
            getActivity().startActivity(intent);
            break;
        default:
            break;
    }
    return true;
}
 
Example 40
Project: C500Companion   File: SettingsActivity.java   View source code 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        startActivity(new Intent(getActivity(), SettingsActivity.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
}