List of usage examples for android.widget AdapterView INVALID_POSITION
int INVALID_POSITION
To view the source code for android.widget AdapterView INVALID_POSITION.
Click Source Link
From source file:com.money.manager.ex.fragment.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) return null; //create view View view = (LinearLayout) inflater.inflate(R.layout.search_activity, container, false); //create listener amount OnClickListener onClickAmount = new OnClickListener() { @Override/* ww w .ja va 2s.c o m*/ public void onClick(View v) { double amount = 0; if (v.getTag() != null && v.getTag() instanceof Double) { amount = (Double) ((TextView) v).getTag(); } InputAmountDialog dialog = InputAmountDialog.getInstance(v.getId(), amount); dialog.show(getSherlockActivity().getSupportFragmentManager(), dialog.getClass().getSimpleName()); } }; //To Amount txtToAmount = (TextView) view.findViewById(R.id.textViewFromAmount); txtToAmount.setOnClickListener(onClickAmount); //From Amount txtFromAmount = (TextView) view.findViewById(R.id.textViewToAmount); txtFromAmount.setOnClickListener(onClickAmount); // accountlist <> to populate the spin spinAccount = (Spinner) view.findViewById(R.id.spinnerAccount); if (mAccountList == null) { mAccountList = new MoneyManagerOpenHelper(getSherlockActivity()).getListAccounts( mApplication.getAccountsOpenVisible(), mApplication.getAccountFavoriteVisible()); mAccountList.add(0, null); for (int i = 0; i <= mAccountList.size() - 1; i++) { if (mAccountList.get(i) != null) { mAccountNameList.add(mAccountList.get(i).getAccountName()); mAccountIdList.add(mAccountList.get(i).getAccountId()); } else { mAccountNameList.add(""); mAccountIdList.add(AdapterView.INVALID_POSITION); } } } // checkbox cbxDeposit = (CheckBox) view.findViewById(R.id.checkBoxDeposit); cbxTransfer = (CheckBox) view.findViewById(R.id.checkBoxTransfer); cbxWithdrawal = (CheckBox) view.findViewById(R.id.checkBoxWithdrawal); // create adapter for spinAccount ArrayAdapter<String> adapterAccount = new ArrayAdapter<String>(getSherlockActivity(), R.layout.sherlock_spinner_item, mAccountNameList); adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinAccount.setAdapter(adapterAccount); //Payee txtSelectPayee = (TextView) view.findViewById(R.id.textViewSelectPayee); txtSelectPayee.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getSherlockActivity(), PayeeActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, REQUEST_PICK_PAYEE); } }); //Category txtSelectCategory = (TextView) view.findViewById(R.id.textViewSelectCategory); txtSelectCategory.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getSherlockActivity(), CategorySubCategoryExpandableListActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, REQUEST_PICK_CATEGORY); } }); if (mStatusItems.size() <= 0) { // arrays to manage Status mStatusItems.add(""); mStatusValues.add(""); mStatusItems.addAll(Arrays.asList(getResources().getStringArray(R.array.status_items))); mStatusValues.addAll(Arrays.asList(getResources().getStringArray(R.array.status_values))); } // create adapter for spinnerStatus spinStatus = (Spinner) view.findViewById(R.id.spinnerStatus); ArrayAdapter<String> adapterStatus = new ArrayAdapter<String>(getSherlockActivity(), R.layout.sherlock_spinner_item, mStatusItems); adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinStatus.setAdapter(adapterStatus); // from date txtFromDate = (TextView) view.findViewById(R.id.textViewFromDate); txtFromDate.setOnClickListener(new OnDateButtonClickListener(txtFromDate)); // to date txtToDate = (TextView) view.findViewById(R.id.textViewToDate); txtToDate.setOnClickListener(new OnDateButtonClickListener(txtToDate)); // transaction number edtTransNumber = (EditText) view.findViewById(R.id.editTextTransNumber); // notes edtNotes = (EditText) view.findViewById(R.id.editTextNotes); return view; }
From source file:com.javielinux.tweettopics2.SearchActivity.java
private void save() { String error = ""; boolean save_tweets = false; String name_value = ""; String searchAnd_value = fragmentAdapter.getSearchGeneralFragment().searchAnd.getText().toString(); search_entity.setValue("words_and", searchAnd_value); if (!searchAnd_value.equals("")) if (name_value.length() <= 0) name_value = searchAnd_value; String searchOr_value = fragmentAdapter.getSearchGeneralFragment().searchOr.getText().toString(); search_entity.setValue("words_or", searchOr_value); if (!searchOr_value.equals("")) if (name_value.length() <= 0) name_value = searchOr_value; String searchNot_value = fragmentAdapter.getSearchGeneralFragment().searchNot.getText().toString(); search_entity.setValue("words_not", searchNot_value); if (!searchNot_value.equals("")) if (name_value.length() <= 0) name_value = searchNot_value; String searchFromUser_value = fragmentAdapter.getSearchGeneralFragment().searchFromUser.getText() .toString();/*from ww w . jav a 2s .c om*/ search_entity.setValue("from_user", searchFromUser_value); if (!searchFromUser_value.equals("")) if (name_value.length() <= 0) name_value = searchFromUser_value; String searchToUser_value = fragmentAdapter.getSearchGeneralFragment().searchToUser.getText().toString(); search_entity.setValue("to_user", searchToUser_value); if (!searchToUser_value.equals("")) if (name_value.length() <= 0) name_value = searchToUser_value; if (searchAnd_value.equals("") && searchOr_value.equals("") && searchNot_value.equals("") && searchFromUser_value.equals("") && searchToUser_value.equals("")) { error = this.getString(R.string.error_search_text); } EditText name = fragmentAdapter.getSearchGeneralFragment().name; if (name.getText().toString().equals("")) { if (name_value.length() > 1) name_value = name_value.substring(0, 1).toUpperCase() + name_value.substring(1); search_entity.setValue("name", name_value); } else { search_entity.setValue("name", name.getText().toString()); } long icon_id = fragmentAdapter.getSearchGeneralFragment().iconId; String token_file = fragmentAdapter.getSearchGeneralFragment().iconFile; search_entity.setValue("icon_id", icon_id); search_entity.setValue("icon_token_file", token_file); if (icon_id > 1) { Entity icon = new Entity("icons", icon_id); search_entity.setValue("icon_big", "drawable/" + icon.getValue("icon")); search_entity.setValue("icon_small", "drawable/" + icon.getValue("icon_small")); } else if (icon_id == 1) { search_entity.setValue("icon_big", Utils.getIconGeneric(this, name_value)); search_entity.setValue("icon_small", Utils.getIconGeneric(this, name_value) + "_small"); } else { search_entity.setValue("icon_big", "file/" + token_file + ".png"); search_entity.setValue("icon_small", "file/" + token_file + "_small.png"); } if (search_entity.getId() < 0) { search_entity.setValue("date_create", Utils.now()); search_entity.setValue("last_modified", Utils.now()); search_entity.setValue("use_count", 0); } Spinner languages = fragmentAdapter.getSearchAdvancedFragment().languages; if (languages.getSelectedItemPosition() != AdapterView.INVALID_POSITION) { String[] language_values = getResources().getStringArray(R.array.languages_values); search_entity.setValue("lang", language_values[languages.getSelectedItemPosition()]); } Spinner attitude = fragmentAdapter.getSearchAdvancedFragment().attitude; if (attitude.getSelectedItemPosition() != AdapterView.INVALID_POSITION) search_entity.setValue("attitude", attitude.getSelectedItemPosition()); Spinner filter = fragmentAdapter.getSearchAdvancedFragment().filter; if (filter.getSelectedItemPosition() != AdapterView.INVALID_POSITION) search_entity.setValue("filter", filter.getSelectedItemPosition()); CheckBox noRetweet = fragmentAdapter.getSearchAdvancedFragment().noRetweet; if (noRetweet.isChecked()) search_entity.setValue("no_retweet", 1); else search_entity.setValue("no_retweet", 0); EditText searchSource = fragmentAdapter.getSearchAdvancedFragment().source; search_entity.setValue("source", searchSource.getText().toString()); CheckBox notifications = fragmentAdapter.getSearchAdvancedFragment().notifications; // Borrar todos los tweets en el caso que deje de notificarse la bsqueda if (!notifications.isChecked() && search_entity.getInt("notifications") == 1) { DataFramework.getInstance().getDB() .execSQL("DELETE FROM tweets WHERE search_id = " + search_entity.getId() + " AND favorite = 0"); search_entity.setValue("last_tweet_id", "0"); search_entity.setValue("last_tweet_id_notifications", "0"); search_entity.setValue("new_tweets_count", "0"); } // Guarda los primeros tweets en el caso de empezar a notificar if (notifications.isChecked() && search_entity.getInt("notifications") == 0) { save_tweets = true; } if (notifications.isChecked()) search_entity.setValue("notifications", 1); else search_entity.setValue("notifications", 0); CheckBox notificationsBar = fragmentAdapter.getSearchAdvancedFragment().notificationsBar; if (notificationsBar.isChecked()) search_entity.setValue("notifications_bar", 1); else search_entity.setValue("notifications_bar", 0); if (fragmentAdapter.getSearchGeoFragment() != null) { CheckBox useGeolocation = fragmentAdapter.getSearchGeoFragment().useGeo; if (useGeolocation.isChecked()) { search_entity.setValue("use_geo", 1); RadioButton typeGeolocationGPS = fragmentAdapter.getSearchGeoFragment().typeGeoGPS; if (typeGeolocationGPS.isChecked()) search_entity.setValue("type_geo", 1); else search_entity.setValue("type_geo", 0); EditText latitude = fragmentAdapter.getSearchGeoFragment().latitude; EditText longitude = fragmentAdapter.getSearchGeoFragment().longitude; try { float latitude_value = Float.parseFloat(latitude.getText().toString()); float longitude_value = Float.parseFloat(longitude.getText().toString()); search_entity.setValue("latitude", latitude_value); search_entity.setValue("longitude", longitude_value); } catch (Exception exception) { error = this.getString(R.string.error_search_coord); } if (error.length() == 0) { SeekBar distance = fragmentAdapter.getSearchGeoFragment().distance; if (distance.getProgress() > 0) { search_entity.setValue("distance", distance.getProgress()); RadioButton typeDistanceKm = fragmentAdapter.getSearchGeoFragment().typeDistanceKM; if (typeDistanceKm.isChecked()) { search_entity.setValue("type_distance", 1); } else { search_entity.setValue("type_distance", 0); } } else { error = this.getString(R.string.error_search_distance); } } } else { search_entity.setValue("use_geo", 0); } } else { search_entity.setValue("use_geo", 0); } if (error.length() == 0) { if (save_tweets) saveTweets(); else exitActivity(); } else { Utils.showMessage(this, error); } }
From source file:mx.com.adolfogarcia.popularmovies.view.fragment.MovieCollectionFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { // If no movie pages have been downloaded, download the first page. if (data.getCount() == 0) { Log.i(LOG_TAG, "Downloading movies because of no local data."); mViewModel.downloadNextMoviePage(); }/* w w w.j av a 2 s.c o m*/ Cursor oldCursor = mMoviePosterAdapter.swapCursor(data); if (oldCursor != null) { oldCursor.close(); } // Scroll to the last selected item if reloading after an event // that causes the first item to be shown (e.g. configuration change). // If reloading because of new movie page downloads, do not scroll back // to selection. if (mBinding.posterGridView.getFirstVisiblePosition() == 0 && mViewModel.getSelectedPosition() != AdapterView.INVALID_POSITION) { mBinding.posterGridView.smoothScrollToPosition(mViewModel.getSelectedPosition()); } }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final int userId = Util.getUserId(Process.myUid()); // Check privacy service client if (!PrivacyService.checkClient()) return;/*w ww . j av a 2 s. c om*/ // Import license file if (Intent.ACTION_VIEW.equals(getIntent().getAction())) if (Util.importProLicense(new File(getIntent().getData().getPath())) != null) Toast.makeText(this, getString(R.string.menu_pro), Toast.LENGTH_LONG).show(); // Set layout setContentView(R.layout.mainlist); setSupportActionBar((Toolbar) findViewById(R.id.widgetToolbar)); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // Set sub title if (Util.hasProLicense(this) != null) getSupportActionBar().setSubtitle(R.string.menu_pro); // Annotate Meta.annotate(this.getResources()); // Get localized restriction name List<String> listRestrictionName = new ArrayList<String>( PrivacyManager.getRestrictions(this).navigableKeySet()); listRestrictionName.add(0, getString(R.string.menu_all)); // Build spinner adapter SpinnerAdapter spAdapter = new SpinnerAdapter(this, android.R.layout.simple_spinner_item); spAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spAdapter.addAll(listRestrictionName); // Handle info ImageView imgInfo = (ImageView) findViewById(R.id.imgInfo); imgInfo.setOnClickListener(new View.OnClickListener() { @SuppressLint("SetJavaScriptEnabled") @Override public void onClick(View view) { int position = spRestriction.getSelectedItemPosition(); if (position != AdapterView.INVALID_POSITION) { String query = (position == 0 ? "restrictions" : (String) PrivacyManager.getRestrictions(ActivityMain.this).values().toArray()[position - 1]); WebView webview = new WebView(ActivityMain.this); webview.getSettings().setUserAgentString("Mozilla/5.0"); // needed for hashtag webview.getSettings().setJavaScriptEnabled(true); webview.loadUrl("https://github.com/M66B/XPrivacy#" + query); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityMain.this); alertDialogBuilder.setTitle((String) spRestriction.getSelectedItem()); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); alertDialogBuilder.setView(webview); alertDialogBuilder.setCancelable(true); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } } }); // Setup category spinner spRestriction = (Spinner) findViewById(R.id.spRestriction); spRestriction.setAdapter(spAdapter); spRestriction.setOnItemSelectedListener(this); int pos = getSelectedCategory(userId); spRestriction.setSelection(pos); // Setup sort mSortMode = Integer.parseInt(PrivacyManager.getSetting(userId, PrivacyManager.cSettingSortMode, "0")); mSortInvert = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingSortInverted, false); // Start task to get app list AppListTask appListTask = new AppListTask(); appListTask.executeOnExecutor(mExecutor, (Object) null); // Check environment Requirements.check(this); // Licensing checkLicense(); // Listen for package add/remove IntentFilter iff = new IntentFilter(); iff.addAction(Intent.ACTION_PACKAGE_ADDED); iff.addAction(Intent.ACTION_PACKAGE_REMOVED); iff.addDataScheme("package"); registerReceiver(mPackageChangeReceiver, iff); mPackageChangeReceiverRegistered = true; boolean showChangelog = true; // First run if (PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingFirstRun, true)) { showChangelog = false; optionAbout(); } // Tutorial if (!PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingTutorialMain, false)) { showChangelog = false; ((ScrollView) findViewById(R.id.svTutorialHeader)).setVisibility(View.VISIBLE); ((ScrollView) findViewById(R.id.svTutorialDetails)).setVisibility(View.VISIBLE); } View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View view) { ViewParent parent = view.getParent(); while (!parent.getClass().equals(ScrollView.class)) parent = parent.getParent(); ((View) parent).setVisibility(View.GONE); PrivacyManager.setSetting(userId, PrivacyManager.cSettingTutorialMain, Boolean.TRUE.toString()); } }; ((Button) findViewById(R.id.btnTutorialHeader)).setOnClickListener(listener); ((Button) findViewById(R.id.btnTutorialDetails)).setOnClickListener(listener); // Legacy if (!PrivacyManager.cVersion3) { long now = new Date().getTime(); String legacy = PrivacyManager.getSetting(userId, PrivacyManager.cSettingLegacy, null); if (legacy == null || now > Long.parseLong(legacy) + 7 * 24 * 60 * 60 * 1000L) { showChangelog = false; PrivacyManager.setSetting(userId, PrivacyManager.cSettingLegacy, Long.toString(now)); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.app_name); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); alertDialogBuilder.setMessage(R.string.title_update_legacy); alertDialogBuilder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Util.viewUri(ActivityMain.this, Uri.parse("https://github.com/M66B/XPrivacy/blob/master/CHANGELOG.md#xprivacy3")); } }); alertDialogBuilder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing } }); // Show dialog AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } } // Show changelog if (showChangelog) { String sVersion = PrivacyManager.getSetting(userId, PrivacyManager.cSettingChangelog, null); Version changelogVersion = new Version(sVersion == null ? "0.0" : sVersion); Version currentVersion = new Version(Util.getSelfVersionName(this)); if (sVersion == null || changelogVersion.compareTo(currentVersion) < 0) optionChangelog(); } }
From source file:com.deange.textfaker.ui.activity.MessageActivity.java
@Override public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenu.ContextMenuInfo menuInfo) { final int itemIndex = mListView.getPositionForView(v); if (itemIndex != AdapterView.INVALID_POSITION) { mLongPressedMessage = new ConversationMessage((Cursor) mAdapter.getItem(itemIndex)); getMenuInflater().inflate(R.menu.message_context_menu, menu); menu.setHeaderTitle(R.string.menu_header_title); }/*from w w w.ja v a 2s . c o m*/ }
From source file:de.geeksfactory.opacclient.frontend.StarredFragment.java
private void setActivatedPosition(int position) { if (position == AdapterView.INVALID_POSITION) { listView.setItemChecked(activatedPosition, false); } else {/* ww w .j a va 2s. c o m*/ listView.setItemChecked(position, true); } activatedPosition = position; }
From source file:de.geeksfactory.opacclient.frontend.StarredFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (activatedPosition != AdapterView.INVALID_POSITION) { // Serialize and persist the activated item position. outState.putInt(STATE_ACTIVATED_POSITION, activatedPosition); }//w w w .ja v a 2s. c om }
From source file:com.game.sns.view.swipelist.SwipeListView.java
/** * Start open item/* w ww. j a v a 2s . com*/ * * @param position * list item * @param action * current action * @param right * to right */ protected void onStartOpen(int position, int action, boolean right) { if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) { swipeListViewListener.onStartOpen(position, action, right); } }
From source file:com.game.sns.view.swipelist.SwipeListView.java
/** * Start close item// ww w . j a va 2 s . c om * * @param position * list item * @param right */ protected void onStartClose(int position, boolean right) { if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) { swipeListViewListener.onStartClose(position, right); } }
From source file:com.game.sns.view.swipelist.SwipeListView.java
/** * Notifies onClickFrontView//from www . ja va2 s . c o m * * @param position * item clicked */ protected void onClickFrontView(int position) { if (swipeListViewListener != null && position != AdapterView.INVALID_POSITION) { swipeListViewListener.onClickFrontView(position); } }