List of usage examples for android.view View.OnClickListener View.OnClickListener
View.OnClickListener
From source file:com.nit.vicky.CardBrowser.java
@Override protected void onCreate(Bundle savedInstanceState) { Themes.applyTheme(this); super.onCreate(savedInstanceState); View mainView = getLayoutInflater().inflate(R.layout.card_browser, null); setContentView(mainView);/*from w w w. j a va2s. co m*/ Themes.setContentStyle(mainView, Themes.CALLER_CARDBROWSER); mCol = AnkiDroidApp.getCol(); if (mCol == null) { reloadCollection(savedInstanceState); return; } mDeckNames = new HashMap<String, String>(); for (long did : mCol.getDecks().allIds()) { mDeckNames.put(String.valueOf(did), mCol.getDecks().name(did)); } registerExternalStorageListener(); Intent i = getIntent(); mWholeCollection = i.hasExtra("fromDeckpicker") && i.getBooleanExtra("fromDeckpicker", false); mBackground = Themes.getCardBrowserBackground(); SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); int sflRelativeFontSize = preferences.getInt("relativeCardBrowserFontSize", DEFAULT_FONT_SIZE_RATIO); String sflCustomFont = preferences.getString("browserEditorFont", ""); mPrefFixArabic = preferences.getBoolean("fixArabicText", false); Resources res = getResources(); mOrderByFields = res.getStringArray(R.array.card_browser_order_labels); try { mOrder = CARD_ORDER_NONE; String colOrder = mCol.getConf().getString("sortType"); for (int c = 0; c < fSortTypes.length; ++c) { if (fSortTypes[c].equals(colOrder)) { mOrder = c; break; } } if (mOrder == 1 && preferences.getBoolean("cardBrowserNoSorting", false)) { mOrder = 0; } mOrderAsc = Upgrade.upgradeJSONIfNecessary(mCol, mCol.getConf(), "sortBackwards", false); // default to descending for non-text fields if (fSortTypes[mOrder].equals("noteFld")) { mOrderAsc = !mOrderAsc; } } catch (JSONException e) { throw new RuntimeException(e); } mCards = new ArrayList<HashMap<String, String>>(); mCardsListView = (ListView) findViewById(R.id.card_browser_list); mCardsAdapter = new SizeControlledListAdapter(this, mCards, R.layout.card_item, new String[] { "word", "sfld", "deck", "flags" }, new int[] { R.id.card_word, R.id.card_sfld, R.id.card_deck, R.id.card_item }, sflRelativeFontSize, sflCustomFont); mCardsAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object arg1, String text) { if (view.getId() == R.id.card_item) { int which = BACKGROUND_NORMAL; if (text.equals("1")) { which = BACKGROUND_SUSPENDED; } else if (text.equals("2")) { which = BACKGROUND_MARKED; } else if (text.equals("3")) { which = BACKGROUND_MARKED_SUSPENDED; } view.setBackgroundResource(mBackground[which]); return true; } else if (view.getId() == R.id.card_deck && text.length() > 0) { view.setVisibility(View.VISIBLE); } return false; } }); //mCardsListView.setAdapter(mCardsAdapter); mCardsListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { mPositionInCardsList = position; long cardId = Long.parseLong(mCards.get(mPositionInCardsList).get("id")); sCardBrowserCard = mCol.getCard(cardId); Intent editCard = new Intent(CardBrowser.this, MultimediaCardEditorActivity.class); //editCard.putExtra(CardEditor.EXTRA_CALLER, CardEditor.CALLER_CARDBROWSER_EDIT); editCard.putExtra(MultimediaCardEditorActivity.EXTRA_CARD_ID, sCardBrowserCard.getId()); startActivityForResult(editCard, EDIT_CARD); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.LEFT); } } }); registerForContextMenu(mCardsListView); mCardsGridView = (StaggeredGridView) findViewById(R.id.card_browser_gridview); mCardsGridView.setAdapter(mGridAdapter); mCardsGridView.setOnItemClickListener(new StaggeredGridView.OnItemClickListener() { @Override public void onItemClick(StaggeredGridView parent, View view, int position, long id) { mPositionInCardsList = position; long cardId = Long.parseLong(mCards.get(mPositionInCardsList).get("id")); sCardBrowserCard = mCol.getCard(cardId); Intent editCard = new Intent(CardBrowser.this, MultimediaCardEditorActivity.class); //editCard.putExtra(CardEditor.EXTRA_CALLER, CardEditor.CALLER_CARDBROWSER_EDIT); editCard.putExtra(MultimediaCardEditorActivity.EXTRA_CARD_ID, sCardBrowserCard.getId()); startActivityForResult(editCard, EDIT_CARD); if (AnkiDroidApp.SDK_VERSION > 4) { ActivityTransitionAnimation.slide(CardBrowser.this, ActivityTransitionAnimation.LEFT); } String imgURL = getImgURL(sCardBrowserCard); Toast.makeText(CardBrowser.this, imgURL, Toast.LENGTH_LONG).show(); } }); mSearchEditText = (EditText) findViewById(R.id.card_browser_search); mSearchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { onSearch(); return true; } return false; } }); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mSearchButton = (ImageButton) findViewById(R.id.card_browser_search_button); mSearchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onSearch(); } }); mSearchTerms = ""; if (mWholeCollection) { mRestrictOnDeck = ""; setTitle(res.getString(R.string.card_browser_all_decks)); } else { try { String deckName = mCol.getDecks().current().getString("name"); mRestrictOnDeck = "deck:'" + deckName + "' "; setTitle(deckName); } catch (JSONException e) { throw new RuntimeException(e); } } mSelectedTags = new HashSet<String>(); if (!preferences.getBoolean("cardBrowserNoSearchOnOpen", false)) { searchCards(); } }
From source file:dess15proj5.fau.cs.osr_amos.mobiletimerecording.ui.SelectedProjectFragment.java
/** * This method sets an onClickListener to the Floating Action Button to create a new session * * methodtype initialization method/*from w w w .j a v a 2s . co m*/ */ private void setClickListenerToFAB() { FloatingActionButton addSessionFAB = (FloatingActionButton) getActivity().findViewById(R.id.addSessionFAB); addSessionFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (isProjectRecordingExpired()) { showToastFinalDateExpiredMessage(); } else { createAddSessionActivity(); } } }); }
From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) onRestoreInstanceState(savedInstanceState); else/*from ww w . j a v a2 s . co m*/ loadExperimentFromIntent(); if (experiment == null) { finish(); return; } // gui setContentView(R.layout.experiment_recording); pager = (ViewPager) findViewById(R.id.centerLayout); updateAdapter(); pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { setCurrentSensor(experiment.getCurrentExperimentRun().getExperimentSensorAt(position)); } @Override public void onPageScrollStateChanged(int state) { } }); startButton = (ImageButton) findViewById(R.id.recordButton); stopButton = (ImageButton) findViewById(R.id.stopButton); newButton = (ImageButton) findViewById(R.id.newButton); setState(null); startButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (state != null) state.onRecordClicked(); } }); stopButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (state != null) state.onStopClicked(); } }); newButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (state != null) state.onNewClicked(); } }); int maxNumberOfRuns = -1; Bundle options = ExperimentHelper.unpackStartExperimentOptions(getIntent()); if (options != null) { maxNumberOfRuns = options.getInt("max_number_of_runs", -1); } experimentRunViewManager = new ExperimentRunViewManager(this, maxNumberOfRuns, experiment); }
From source file:mroza.forms.ChooseProgramActivity.java
private void enableShowAllButton(boolean enable) { LinearLayout layout = (LinearLayout) findViewById(R.id.LayoutGrid); Button button = (Button) findViewById(R.id.show_all_programs_button_id); if (enable && button == null) { button = new Button(this); button.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); button.setText(R.string.show_all_programs); button.setId(R.id.show_all_programs_button_id); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { List<ChildTable> childTables; clearFilters(true);/* w w w.j av a2s . co m*/ clearSearchField(); Term selectedTerm = getSelectedTerm(); childTables = ChildTablesRepository.getChildTableByTerm(ChooseProgramActivity.this, selectedTerm, child); handleListViewBehavior(childTables, selectedTerm); enableShowAllButton(false); } }); layout.addView(button, 1); } else if (!enable && button != null) { layout.removeView(button); } }
From source file:uk.ac.hutton.ics.buntata.activity.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { /* Inflate the menu */ MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.main_menu, menu); /* Find the search menu item */ final MenuItem searchItem = menu.findItem(R.id.action_search); /* Get the search manager */ SearchManager searchManager = (SearchManager) MainActivity.this.getSystemService(Context.SEARCH_SERVICE); /* Get the actual search view */ searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final MenuItem barcodeItem = menu.findItem(R.id.action_scan_barcode); searchView.setMaxWidth(displayMetrics.widthPixels / 2); searchView.setSearchableInfo(searchManager.getSearchableInfo(MainActivity.this.getComponentName())); searchView.setQueryHint(getString(R.string.search_query_hint)); /* Listen to submit events */ searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override// w ww .j a va 2s. co m public boolean onQueryTextSubmit(String query) { /* Trim leading and trailing spaces that some keyboards will add */ query = query.trim(); MainActivity.this.query = query; filter(query); searchView.clearFocus(); return false; } @Override public boolean onQueryTextChange(String s) { /* Close the search field when the search string is empty */ if (StringUtils.isEmpty(s)) { searchView.setIconified(true); searchView.clearFocus(); } return false; } }); searchView.setOnCloseListener(new SearchView.OnCloseListener() { @Override public boolean onClose() { MainActivity.this.query = null; filter(""); barcodeItem.setVisible(false); return false; } }); searchView.setOnSearchClickListener(new View.OnClickListener() { @Override public void onClick(View view) { barcodeItem.setVisible(true); } }); } return super.onCreateOptionsMenu(menu); }
From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java
@Override public void onCommentListingRequestPostDownloaded(final RedditPreparedPost post) { final Context context = getActivity(); if (mPost == null) { final RRThemeAttributes attr = new RRThemeAttributes(context); mPost = post;// w ww .j av a 2 s .c o m isArchived = post.isArchived; final RedditPostHeaderView postHeader = new RedditPostHeaderView(getActivity(), this.mPost); mCommentListingManager.addPostHeader(postHeader); ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); if (post.src.getSelfText() != null) { final ViewGroup selfText = post.src.getSelfText().buildView(getActivity(), attr.rrMainTextCol, 14f * mCommentFontScale, mShowLinkButtons); selfText.setFocusable(false); selfText.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); final int paddingPx = General.dpToPixels(context, 10); final FrameLayout paddingLayout = new FrameLayout(context); final TextView collapsedView = new TextView(context); collapsedView.setText("[ + ] " + getActivity().getString(R.string.collapsed_self_post)); collapsedView.setVisibility(View.GONE); collapsedView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.addView(selfText); paddingLayout.addView(collapsedView); paddingLayout.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); paddingLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (selfText.getVisibility() == View.GONE) { selfText.setVisibility(View.VISIBLE); collapsedView.setVisibility(View.GONE); } else { selfText.setVisibility(View.GONE); collapsedView.setVisibility(View.VISIBLE); } } }); // TODO mListHeaderNotifications.setBackgroundColor(Color.argb(35, 128, 128, 128)); mCommentListingManager.addPostSelfText(paddingLayout); } if (!General.isTablet(context, PreferenceManager.getDefaultSharedPreferences(context))) { getActivity().setTitle(post.src.getTitle()); } if (mCommentListingManager.isSearchListing()) { final CommentSubThreadView searchCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_search_thread_title); mCommentListingManager.addNotification(searchCommentThreadView); } else if (!mAllUrls.isEmpty() && mAllUrls.get(0).pathType() == RedditURLParser.POST_COMMENT_LISTING_URL && mAllUrls.get(0).asPostCommentListURL().commentId != null) { final CommentSubThreadView specificCommentThreadView = new CommentSubThreadView(getActivity(), mAllUrls.get(0).asPostCommentListURL(), R.string.comment_header_specific_thread_title); mCommentListingManager.addNotification(specificCommentThreadView); } // TODO pref (currently 10 mins) if (mCachedTimestamp != null && RRTime.since(mCachedTimestamp) > 10 * 60 * 1000) { final TextView cacheNotif = (TextView) LayoutInflater.from(getActivity()) .inflate(R.layout.cached_header, null, false); cacheNotif.setText(getActivity().getString(R.string.listing_cached, RRTime.formatDateTime(mCachedTimestamp, getActivity()))); mCommentListingManager.addNotification(cacheNotif); } } }
From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java
private void updateSearchView(final String query) { View view = getView();//from www . j a v a 2 s . com if (view == null) { logger.error("No view created yet!!! query: " + query); return; } RelativeLayout callSearchLayout = (RelativeLayout) view.findViewById(R.id.callSearchLayout); if (StringUtils.isNullOrEmpty(query)) { if (callSearchLayout != null) { callSearchLayout.setVisibility(View.INVISIBLE); callSearchLayout.getLayoutParams().height = 0; } } else { if (callSearchLayout != null) { TextView searchContactView = (TextView) callSearchLayout.findViewById(R.id.callSearchContact); searchContactView.setText(query); callSearchLayout.getLayoutParams().height = searchContactView.getResources() .getDimensionPixelSize(R.dimen.account_list_row_height); callSearchLayout.setVisibility(View.VISIBLE); final ImageButton callButton = (ImageButton) callSearchLayout.findViewById(R.id.contactCallButton); callButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AndroidCallUtil.createAndroidCall(getActivity(), callButton, query); } }); } } }
From source file:com.juick.android.ThreadActivity.java
public void onReplySelected(final JuickMessage msg) { selectedReply = msg;/* w w w . j a v a 2 s . com*/ rid = msg.getRID(); if (rid > 0) { SpannableStringBuilder ssb = new SpannableStringBuilder(); String inreplyto = getResources().getString(R.string.In_reply_to_) + " "; ssb.append(inreplyto).append(msg.Text); ssb.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, inreplyto.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); tvReplyTo.setText(ssb); setHeight(replyToContainer, ActionBar.LayoutParams.WRAP_CONTENT); showThread.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { tf.showThread(msg, false); } }); } else { setHeight(replyToContainer, 0); } }
From source file:nf.frex.android.FrexActivity.java
private void prepareColorsDialog(final Dialog dialog) { //Log.d(TAG, "prepareColorsDialog() entered"); getColorSchemes();/*from w w w . j a v a2s . com*/ //Log.d(TAG, "prepareColorsDialog: new bitmaps are being created"); Bitmap[] colorSchemeIcons = new Bitmap[colorSchemes.getSize()]; for (int i = 0; i < colorSchemeIcons.length; i++) { ColorScheme colorScheme = colorSchemes.getValue(i); colorSchemeIcons[i] = colorScheme.getGradientIcon(); } int checkedIndex = Registries.colorSchemes.getIndex(view.getColorSchemeId()); //Log.d(TAG, "prepareColorsDialog: checkedIndex = " + checkedIndex); final Spinner colorTableSpinner = (Spinner) dialog.findViewById(R.id.color_table_spinner); colorTableSpinner.setAdapter(new ImageArrayAdapter(this, 0, colorSchemeIcons)); colorTableSpinner.setSelection(checkedIndex, false); colorTableSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View spinnerView, int position, long id) { view.setColorSchemeId(Registries.colorSchemes.getId(position)); view.setColorScheme(Registries.colorSchemes.getValue(position)); view.recomputeColors(); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); final SeekBar colorFactorSeekBar = (SeekBar) dialog.findViewById(R.id.color_gain_seek_bar); final double colorFactorMin = -3.0; final double colorFactorMax = 2.0; final SeekBarConfigurer colorFactorSeekBarConfigurer = SeekBarConfigurer.create(colorFactorSeekBar, colorFactorMin, colorFactorMax, true, view.getColorGain()); colorFactorSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { view.setColorGain((float) colorFactorSeekBarConfigurer.getValue()); view.recomputeColors(); } }); final SeekBar colorBiasSeekBar = (SeekBar) dialog.findViewById(R.id.color_offset_seek_bar); final double colorBiasMin = 0; final double colorBiasMax = 1024; final SeekBarConfigurer colorBiasSeekBarConfigurer = SeekBarConfigurer.create(colorBiasSeekBar, colorBiasMin, colorBiasMax, false, view.getColorOffset()); colorBiasSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { view.setColorOffset((float) colorBiasSeekBarConfigurer.getValue()); view.recomputeColors(); } }); final CheckBox colorRepeatCheckBox = (CheckBox) dialog.findViewById(R.id.color_repeat); colorRepeatCheckBox.setChecked(view.isColorRepeat()); colorRepeatCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { view.setColorRepeat(isChecked); view.recomputeColors(); } }); Button randomButton = (Button) dialog.findViewById(R.id.random_button); randomButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { colorTableSpinner.setSelection((int) (Math.random() * colorSchemes.getSize())); colorFactorSeekBarConfigurer.setRandomValue(); colorBiasSeekBarConfigurer.setRandomValue(); view.recomputeColors(); } }); Button getPalFromImgButton = (Button) dialog.findViewById(R.id.get_pal_from_img_button); getPalFromImgButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); dialog.dismiss(); startActivityForResult(photoPickerIntent, SELECT_PICTURE_REQUEST_CODE); } }); //Log.d(TAG, "prepareColorsDialog() exited"); }
From source file:fr.paug.droidcon.ui.BaseActivity.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that * shows which account the user is logged in as, and lets them switch accounts. It also * shows the user's Google+ cover photo as background. *//*from ww w . j ava2 s . c om*/ private void setupAccountBox() { mAccountListContainer = (LinearLayout) findViewById(R.id.account_list); if (mAccountListContainer == null) { //This activity does not have an account box return; } final View chosenAccountView = findViewById(R.id.chosen_account_view); Account chosenAccount = AccountUtils.getActiveAccount(this); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); mAccountListContainer.setVisibility(View.INVISIBLE); } AccountManager am = AccountManager.get(this); Account[] accountArray = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE); List<Account> accounts = new ArrayList<Account>(Arrays.asList(accountArray)); accounts.remove(chosenAccount); ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); TextView nameTextView = (TextView) chosenAccountView.findViewById(R.id.profile_name_text); TextView email = (TextView) chosenAccountView.findViewById(R.id.profile_email_text); mExpandAccountBoxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator); String name = AccountUtils.getPlusName(this); if (name == null) { nameTextView.setVisibility(View.GONE); } else { nameTextView.setText(name); } String imageUrl = AccountUtils.getPlusImageUrl(this); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(this); if (coverImageUrl != null) { mImageLoader.loadImage(coverImageUrl, coverImageView); } else { coverImageView.setImageResource(R.drawable.default_cover); } email.setText(chosenAccount.name); if (accounts.isEmpty()) { // There's only one account on the device, so no need for a switcher. mExpandAccountBoxIndicator.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); chosenAccountView.setEnabled(false); return; } chosenAccountView.setEnabled(true); mExpandAccountBoxIndicator.setVisibility(View.VISIBLE); chosenAccountView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAccountBoxExpanded = !mAccountBoxExpanded; setupAccountBoxToggle(); } }); setupAccountBoxToggle(); populateAccountList(accounts); }