List of usage examples for android.widget SimpleCursorAdapter SimpleCursorAdapter
@Deprecated public SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to)
From source file:com.google.android.apps.paco.ExploreDataActivity.java
protected void gotoVarSelection(final int whichOption) { mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.variable_choices, null); setContentView(mainLayout);// ww w . j av a2s . c o m final Button varOkButton = (Button) findViewById(R.id.VarOkButton); switch (whichOption) { case 1: varOkButton.setText(R.string.show_trends_button); break; case 2: varOkButton.setText(R.string.show_relationships_button); break; case 3: varOkButton.setText(R.string.show_distributions_button); break; default: varOkButton.setText(" " + getString(R.string.ok) + " "); break; } varOkButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showVisualizations(checkedChoices, whichOption); } }); userPrefs = new UserPreferences(this); list = (ListView) findViewById(R.id.exploreable_experiments_list); experimentProviderUtil = new ExperimentProviderUtil(this); Cursor cursor = managedQuery(ExperimentColumns.JOINED_EXPERIMENTS_CONTENT_URI, new String[] { ExperimentColumns._ID, ExperimentColumns.TITLE }, null, null, null); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor, new String[] { ExperimentColumns.TITLE }, new int[] { android.R.id.text1 }) { }; list.setAdapter(adapter); list.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> listview, View textview, int position, long id) { Experiment experiment = experimentProviderUtil.getExperiment(id); if (experiment != null) { inputIds = getInputIds(experiment.getInputs()); inpNames = getInputNames(experiment.getInputs()); renderMultiSelectListButton(id, (TextView) ((TwoLineListItem) textview).getChildAt(1)); varOkButton.setVisibility(View.VISIBLE); } else { Toast.makeText(ExploreDataActivity.this, R.string.experiment_choice_warning, Toast.LENGTH_SHORT) .show(); } } }); }
From source file:com.facebook.samples.booleanog.LogicActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); uiHelper = new UiLifecycleHelper(this, callback); uiHelper.onCreate(savedInstanceState); setContentView(R.layout.main);/*from ww w . j ava 2 s . c om*/ // Views logicButton = (Button) findViewById(R.id.logic_button); friendsButton = (Button) findViewById(R.id.friends_button); settingsButton = (Button) findViewById(R.id.settings_button); contentButton = (Button) findViewById(R.id.content_button); logicGroup = (ViewGroup) findViewById(R.id.logic_group); leftSpinner = (Spinner) findViewById(R.id.left_spinner); rightSpinner = (Spinner) findViewById(R.id.right_spinner); andButton = (Button) findViewById(R.id.and_button); orButton = (Button) findViewById(R.id.or_button); resultText = (TextView) findViewById(R.id.result_text); postResultText = (TextView) findViewById(R.id.post_result_text); friendsGroup = (ViewGroup) findViewById(R.id.friends_group); ListView friendActivityList = (ListView) findViewById(R.id.friend_activity_list); String[] mapColumnNames = { "date", "action" }; int[] mapViewIds = { R.id.friend_action_date, R.id.friend_action_data }; friendActivityAdapter = new SimpleCursorAdapter(this, R.layout.friend_activity_row, createEmptyCursor(), mapColumnNames, mapViewIds); friendActivityList.setAdapter(friendActivityAdapter); friendActivityProgressBar = (ProgressBar) findViewById(R.id.friend_activity_progress_bar); settingsGroup = (ViewGroup) findViewById(R.id.settings_group); contentGroup = (ViewGroup) findViewById(R.id.content_group); contentImage = (ImageView) findViewById(R.id.content_image); contentSpinner = (Spinner) findViewById(R.id.content_spinner); // Fragments FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); friendPickerFragment = (FriendPickerFragment) fragmentManager.findFragmentById(R.id.friend_picker_fragment); if (friendPickerFragment == null) { Bundle args = new Bundle(); args.putBoolean(FriendPickerFragment.SHOW_TITLE_BAR_BUNDLE_KEY, false); friendPickerFragment = new FriendPickerFragment(args); transaction.add(R.id.friend_picker_fragment, friendPickerFragment); } userSettingsFragment = (UserSettingsFragment) fragmentManager.findFragmentById(R.id.login_fragment); if (userSettingsFragment == null) { userSettingsFragment = new UserSettingsFragment(); transaction.add(R.id.login_fragment, userSettingsFragment); } transaction.commit(); // Spinners ArrayAdapter<CharSequence> truthAdapter = ArrayAdapter.createFromResource(this, R.array.truth_values, android.R.layout.simple_spinner_item); truthAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); leftSpinner.setAdapter(truthAdapter); rightSpinner.setAdapter(truthAdapter); contentSpinner.setAdapter(truthAdapter); leftSpinner.setSelection(0); rightSpinner.setSelection(0); // Navigation for (Button button : Arrays.asList(logicButton, friendsButton, settingsButton, contentButton)) { initializeNavigationButton(button); } // Logic initializeCalculationButton(andButton); initializeCalculationButton(orButton); // Friends friendPickerFragment.setOnErrorListener(new PickerFragment.OnErrorListener() { @Override public void onError(PickerFragment<?> fragment, FacebookException error) { LogicActivity.this.onError(error); } }); friendPickerFragment.setUserId("me"); friendPickerFragment.setMultiSelect(false); friendPickerFragment.setOnSelectionChangedListener(new PickerFragment.OnSelectionChangedListener() { @Override public void onSelectionChanged(PickerFragment<?> fragment) { LogicActivity.this.onFriendSelectionChanged(); } }); friendPickerFragment.setExtraFields(Arrays.asList(INSTALLED)); friendPickerFragment.setFilter(new PickerFragment.GraphObjectFilter<GraphUser>() { @Override public boolean includeItem(GraphUser graphObject) { Boolean installed = graphObject.cast(GraphUserWithInstalled.class).getInstalled(); return (installed != null) && installed.booleanValue(); } }); // Content contentSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { LogicActivity.this.onContentSelectionChanged(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { LogicActivity.this.onContentSelectionChanged(); } }); // Restore saved state Button startButton = logicButton; if (savedInstanceState != null) { leftSpinner.setSelection(savedInstanceState.getInt(SAVE_LEFT_OPERAND_SELECTION)); rightSpinner.setSelection(savedInstanceState.getInt(SAVE_RIGHT_OPERAND_SELECTION)); contentSpinner.setSelection(savedInstanceState.getInt(SAVE_CONTENT_SELECTION)); resultText.setText(savedInstanceState.getString(SAVE_RESULT_TEXT)); postResultText.setText(savedInstanceState.getString(SAVE_POST_RESULT_TEXT)); activeTab = savedInstanceState.getString(SAVE_ACTIVE_TAB); pendingPost = savedInstanceState.getBundle(SAVE_PENDING); friendActionList = savedInstanceState.getParcelableArrayList(SAVE_FRIEND_ACTIONS); if ((friendActionList != null) && (friendActionList.size() > 0)) { updateCursor(friendActionList); } if (getString(R.string.navigate_friends).equals(activeTab)) { startButton = friendsButton; } else if (getString(R.string.navigate_content).equals(activeTab)) { startButton = contentButton; } else if (getString(R.string.navigate_settings).equals(activeTab)) { startButton = settingsButton; } } if (!handleNativeLink()) { onNavigateButtonClick(startButton); } }
From source file:eu.thecoder4.gpl.pleftdroid.PleftDroidActivity.java
private void fillList() { mDbAdapter.open();//from ww w .ja v a2 s . c om // Get all of the appointments from the database and create the item list Cursor c = mDbAdapter.fetchAllAppointmentsList(); startManagingCursor(c); if (c.getCount() > 0) { String[] from = null; int[] to = null; SimpleCursorAdapter apts = null; if (isPrefDetailListSet()) { from = new String[] { PleftDroidDbAdapter.COL_DESC, PleftDroidDbAdapter.COL_ROLE, PleftDroidDbAdapter.COL_STATUS, PleftDroidDbAdapter.COL_PSERVER, PleftDroidDbAdapter.COL_USER }; to = new int[] { R.id.adesc, R.id.arole, R.id.astatus, R.id.apserver, R.id.auser }; // Now create an array adapter and set it to display using our row apts = new SimpleCursorAdapter(this, R.layout.event_row_details, c, from, to); } else { from = new String[] { PleftDroidDbAdapter.COL_DESC, PleftDroidDbAdapter.COL_ROLE, PleftDroidDbAdapter.COL_STATUS }; to = new int[] { R.id.adesc, R.id.arole, R.id.astatus }; // Now create an array adapter and set it to display using our row apts = new SimpleCursorAdapter(this, R.layout.event_row, c, from, to); } this.getListView().destroyDrawingCache(); this.getListView().setVisibility(ListView.INVISIBLE); this.getListView().setVisibility(ListView.VISIBLE); this.getWindow().getDecorView().invalidate(); setListAdapter(apts); apts.notifyDataSetChanged(); } mDbAdapter.close(); }
From source file:nl.sogeti.android.gpstracker.viewer.TrackList.java
private void displayCursor(Cursor tracksCursor) { SectionedListAdapter sectionedAdapter = new SectionedListAdapter(this); String[] fromColumns = new String[] { Tracks.NAME, Tracks.CREATION_TIME, Tracks._ID }; int[] toItems = new int[] { R.id.listitem_name, R.id.listitem_from, R.id.bcSyncedCheckBox }; SimpleCursorAdapter trackAdapter = new SimpleCursorAdapter(this, R.layout.trackitem, tracksCursor, fromColumns, toItems);/*from w ww .j a v a2s .c o m*/ sectionedAdapter.addSection("", trackAdapter); // Enrich the track adapter with Breadcrumbs adapter data trackAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() { @Override public boolean setViewValue(View view, final Cursor cursor, int columnIndex) { if (columnIndex == 0) { final long trackId = cursor.getLong(0); final String trackName = cursor.getString(1); // Show the check if Breadcrumbs is online final CheckBox checkbox = (CheckBox) view; final ProgressBar progressbar = (ProgressBar) ((View) view.getParent()) .findViewById(R.id.bcExportProgress); checkbox.setVisibility(View.INVISIBLE); checkbox.setOnCheckedChangeListener(null); return true; } return false; } }); setListAdapter(sectionedAdapter); }
From source file:org.opensmc.mytracks.cyclesmc.MainInput.java
void populateList(ListView lv) { // Get list from the real phone database. W00t! DbAdapter mDb = new DbAdapter(MainInput.this); mDb.open();/* www . j a va 2 s . c o m*/ // Clean up any bad trips & coords from crashes int cleanedTrips = mDb.cleanTables(); if (cleanedTrips > 0) { Toast.makeText(getBaseContext(), "" + cleanedTrips + " bad trip(s) removed.", Toast.LENGTH_SHORT) .show(); } try { Cursor allTrips = mDb.fetchAllTrips(); SimpleCursorAdapter sca = new SimpleCursorAdapter(this, R.layout.twolinelist, allTrips, new String[] { "purp", "fancystart", "fancyinfo" }, new int[] { R.id.TextView01, R.id.TextView03, R.id.TextInfo }); lv.setAdapter(sca); TextView counter = (TextView) findViewById(R.id.TextViewPreviousTrips); int numtrips = allTrips.getCount(); switch (numtrips) { case 0: counter.setText("No saved trips."); break; case 1: counter.setText("1 saved trip:"); break; default: counter.setText("" + numtrips + " saved trips:"); } // allTrips.close(); } catch (SQLException sqle) { // Do nothing, for now! } mDb.close(); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int pos, long id) { Intent i = new Intent(MainInput.this, ShowMap.class); i.putExtra("showtrip", id); startActivity(i); } }); registerForContextMenu(lv); }
From source file:info.staticfree.android.units.Units.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ABOUT: { final Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.dialog_about_title); builder.setIcon(R.drawable.icon); try {// www . j a v a 2 s . com final WebView wv = new WebView(this); final InputStream is = getAssets().open("README.xhtml"); wv.loadDataWithBaseURL("file:///android_asset/", inputStreamToString(is), "application/xhtml+xml", "utf-8", null); wv.setBackgroundColor(0); builder.setView(wv); } catch (final IOException e) { builder.setMessage(R.string.err_no_load_about); e.printStackTrace(); } builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setResult(RESULT_OK); } }); return builder.create(); } case DIALOG_ALL_UNITS: { final Builder b = new Builder(Units.this); b.setTitle(R.string.dialog_all_units_title); final ExpandableListView unitExpandList = new ExpandableListView(Units.this); unitExpandList.setId(android.R.id.list); final String[] groupProjection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT }; // any selection below will select from the grouping description final Cursor cursor = managedQuery(UsageEntry.CONTENT_URI_CONFORM_TOP, groupProjection, null, null, UnitUsageDBHelper.USAGE_SORT); unitExpandList.setAdapter(new UnitsExpandableListAdapter(cursor, this, android.R.layout.simple_expandable_list_item_1, android.R.layout.simple_expandable_list_item_1, new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 }, new String[] { UsageEntry._UNIT }, new int[] { android.R.id.text1 })); unitExpandList.setCacheColorHint(0); unitExpandList.setOnChildClickListener(allUnitChildClickListener); b.setView(unitExpandList); return b.create(); } case DIALOG_UNIT_CATEGORY: { final Builder b = new Builder(new ContextThemeWrapper(this, android.R.style.Theme_Black)); final String[] from = { UsageEntry._UNIT }; final int[] to = { android.R.id.text1 }; b.setTitle("all units"); final String[] projection = { UsageEntry._ID, UsageEntry._UNIT, UsageEntry._FACTOR_FPRINT }; final Cursor c = managedQuery(UsageEntry.CONTENT_URI, projection, null, null, UnitUsageDBHelper.USAGE_SORT); dialogUnitCategoryList = new SimpleCursorAdapter(this, android.R.layout.select_dialog_item, c, from, to); b.setAdapter(dialogUnitCategoryList, dialogUnitCategoryOnClickListener); return b.create(); } case DIALOG_LOADING_UNITS: { final ProgressDialog pd = new ProgressDialog(this); pd.setIndeterminate(true); pd.setTitle(R.string.app_name); pd.setMessage(getText(R.string.dialog_loading_units)); return pd; } default: throw new IllegalArgumentException("Unknown dialog ID:" + id); } }
From source file:uk.co.droidinactu.ebooklauncher.EBookLauncherActivity.java
private void updateCollectionlist1() { new Thread() { @Override/*w ww .ja va 2 s. c o m*/ public void run() { setName("updateCollectionlist1()"); final String clctname = EditPreferences .getCollectionName1(EBookLauncherActivity.this.getApplication()); try { if (clctname.equals(EBookLauncherActivity.this.getResources() .getString(R.string.pref_collection_recently_added))) { cursrCollcnts1 = myApp.dataMdl.getRecentlyAdded(EBookLauncherActivity.this); final int nbrItems = cursrCollcnts1.getCount(); if (collection1Start >= nbrItems) { collection1Start = nbrItems - 1; } final String tmpStr; if (collection1Start + 1 < nbrItems) { tmpStr = String.format( EBookLauncherActivity.this .getResources().getString(R.string.page1_nbr_item_format_1), collection1Start + 1, collection1Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF > nbrItems ? nbrItems : collection1Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, nbrItems); } else { tmpStr = String.format(EBookLauncherActivity.this.getResources() .getString(R.string.page1_nbr_item_format_2), collection1Start + 1, nbrItems); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { lblCollection1.setText(clctname + " " + tmpStr); } }); cursrCollcnts1.close(); cursrCollcnts1 = myApp.dataMdl.getRecentlyAdded(EBookLauncherActivity.this, collection1Start, EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF); } else if (clctname.equals(EBookLauncherActivity.this.getResources() .getString(R.string.pref_collection_periodicals))) { cursrCollcnts1 = myApp.dataMdl.getPeriodicals(EBookLauncherActivity.this); final int nbrItems = cursrCollcnts1.getCount(); if (collection1Start >= nbrItems) { collection1Start = nbrItems - 1; } final String tmpStr; if (collection1Start + 1 < nbrItems) { tmpStr = String.format( EBookLauncherActivity.this .getResources().getString(R.string.page1_nbr_item_format_1), collection1Start + 1, collection1Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF > nbrItems ? nbrItems : collection1Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, nbrItems); } else { tmpStr = String.format(EBookLauncherActivity.this.getResources() .getString(R.string.page1_nbr_item_format_2), collection1Start + 1, nbrItems); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { lblCollection1.setText(clctname + " " + tmpStr); } }); cursrCollcnts1.close(); cursrCollcnts1 = myApp.dataMdl.getPeriodicals(EBookLauncherActivity.this, collection1Start, EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF); } else { cursrCollcnts1 = myApp.dataMdl.getBooksInCollection(clctname, BookSortBy.TITLE); final int nbrItems = cursrCollcnts1.getCount(); if (collection1Start >= nbrItems) { collection1Start = nbrItems - 1; } final String tmpStr; if (collection1Start + 1 < nbrItems) { tmpStr = String.format( EBookLauncherActivity.this .getResources().getString(R.string.page1_nbr_item_format_1), collection1Start + 1, collection1Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF > nbrItems ? nbrItems : collection1Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, nbrItems); } else { tmpStr = String.format(EBookLauncherActivity.this.getResources() .getString(R.string.page1_nbr_item_format_2), collection1Start + 1, nbrItems); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { lblCollection1.setText(clctname + " " + tmpStr); } }); cursrCollcnts1.close(); cursrCollcnts1 = myApp.dataMdl.getBooksInCollection(clctname, collection1Start, EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, BookSortBy.TITLE); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { if (EditPreferences.useFilenames(EBookLauncherActivity.this)) { listAdapterCollectns1 = new SimpleCursorAdapter(EBookLauncherActivity.this, R.layout.book_grid_item_filename, cursrCollcnts1, DeviceFactory.getBookColumnsToMap(true), BooksActivity.bookGridColsMapToFilename); } else { int layoutId = R.layout.book_grid_item; if (android.os.Build.MANUFACTURER .equalsIgnoreCase(DeviceFactory.DEVICE_MANUFACTURER_BARNES_AND_NOBLE)) { layoutId = R.layout.book_grid_item_nook; } listAdapterCollectns1 = new SimpleCursorAdapter(EBookLauncherActivity.this, layoutId, cursrCollcnts1, DeviceFactory.getBookColumnsToMap(false), BooksActivity.bookGridColsMapTo); } EBookLauncherActivity.this.setupList(listviewCollectns1, listAdapterCollectns1, cursrCollcnts1); } }); } catch (final Exception e) { Log.e(EBookLauncherApplication.LOG_TAG + EBookLauncherActivity.LOG_TAG, "Error Pop List", e); } } }.start(); }
From source file:com.xmobileapp.rockplayer.RockPlayer.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { /*/*from w ww. jav a 2 s. c om*/ * Shuffle */ case 0: if (this.SHUFFLE) this.SHUFFLE = false; else this.SHUFFLE = true; try { playerServiceIface.setShuffle(this.SHUFFLE); } catch (RemoteException e) { e.printStackTrace(); } RockOnPreferenceManager settings = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH); settings.putBoolean("Shuffle", this.SHUFFLE); return true; /* * Search */ case 1: if (GRATIS) { showLitePopup(); return true; } //this.hideMainUI(); this.showSongSearch(); this.songSearchTextView.requestFocus(); Cursor allSongsCursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, SONG_COLS, // we should minimize the number of columns null, // all songs null, // parameters to the previous parameter - which is null also null // sort order, SQLite-like ); SimpleCursorAdapter songAdapter = new SimpleCursorAdapter(this, R.layout.simple_dropdown_item_2line, allSongsCursor, new String[] { MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST }, new int[] { R.id.text1, R.id.text2 }); FilterQueryProvider songSearchFilterProvider = new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { String whereClause = MediaStore.Audio.Media.TITLE + " LIKE '%" + constraint + "%'" + " OR " + MediaStore.Audio.Media.ARTIST + " LIKE '%" + constraint + "%'"; Log.i("SEARCH", whereClause); //whereClause = null; Cursor songsCursor = contentResolver.query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, SONG_COLS, // we should minimize the number of columns whereClause, // songs where the title or artist name matches null, // parameters to the previous parameter - which is null also null // sort order, SQLite-like ); return songsCursor; } }; songAdapter.setFilterQueryProvider(songSearchFilterProvider); this.songSearchTextView.setAdapter(songAdapter); songAdapter .setStringConversionColumn(allSongsCursor.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE)); //this.songSearchTextView.setOnKeyListener(songSearchKeyListener); return true; /* * Share */ case 5: if (GRATIS) { showLitePopup(); return true; } ShareSong shareSong = new ShareSong(context, songCursor); shareSong.shareByMail(); return true; /* * Get Art */ case 3: // if(GRATIS){ // showLitePopup(); // return true; // } albumReloadProgressDialog = new ProgressDialog(this); albumReloadProgressDialog.setIcon(R.drawable.ic_menu_music_library); albumReloadProgressDialog.setTitle("Loading Album Art"); albumReloadProgressDialog.setMessage("Waiting for Last.FM connection"); // TODO: set powered by Last.FM albumReloadProgressDialog.show(); Thread albumArtThread = new Thread() { public void run() { try { LastFmAlbumArtImporter lastFmArtImporter = new LastFmAlbumArtImporter(context); lastFmArtImporter.getAlbumArt(); } catch (Exception e) { e.printStackTrace(); } } }; //albumArtThread.setUncaughtExceptionHandler(albumArtUncaughtExceptionHandler); albumArtThread.start(); //containerLayout.addView(albumReloadProgressDialog); return true; /* * Concerts */ case 4: if (GRATIS) { showLitePopup(); return true; } this.hideMainUI(); this.mainUIContainer.setVisibility(View.GONE); //this.hideHelpUI(); this.showEventUI(); /* * Concert Radius Thing */ // TODO: need a metric // SharedPreferences prefs = getSharedPreferences(PREFS_NAME, 0); RockOnPreferenceManager prefs = new RockOnPreferenceManager(FILEX_PREFERENCES_PATH); concertRadius = prefs.getLong("ConcertRadius", (long) (this.CONCERT_RADIUS_DEFAULT)); this.eventListRadius.setText(String.valueOf(Math.round((float) concertRadius / 1000))); /* * Show a dialog to give some nice feedback to the user */ concertAnalysisProgressDialog = new ProgressDialog(this); concertAnalysisProgressDialog.setIcon(android.R.drawable.ic_menu_today); concertAnalysisProgressDialog.setTitle("Analysing concert information"); concertAnalysisProgressDialog.setMessage("Waiting for Last.FM connection"); concertAnalysisProgressDialog.show(); /* * Analyze concert info */ lastFmEventImporter = new LastFmEventImporter(context); new Thread() { public void run() { try { lastFmEventImporter.getArtistEvents(); } catch (SAXException e) { e.printStackTrace(); } catch (ParserConfigurationException e) { e.printStackTrace(); } } }.start(); return true; /* * Playlists */ case 6: if (GRATIS) { showLitePopup(); return true; } /* * Get the views and make them visible */ String sortOrder = MediaStore.Audio.Playlists.NAME + " ASC"; Cursor playlistAllCursor = contentResolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, this.PLAYLIST_COLS, null, null, sortOrder); /* * Create Array with custom playlist + system playlists */ Playlist playlistTemp; ArrayList<Playlist> playlistArray = new ArrayList<Playlist>(); /* ALL Playlist*/ playlistTemp = new Playlist(); playlistTemp.id = constants.PLAYLIST_ALL; playlistTemp.name = "All songs"; playlistArray.add(playlistTemp); /* Recently Added */ playlistTemp = new Playlist(); playlistTemp.id = constants.PLAYLIST_RECENT; playlistTemp.name = "Recently Added"; playlistArray.add(playlistTemp); /* ... other system playlists ... */ /* add every playlist in the media store */ while (playlistAllCursor.moveToNext()) { playlistTemp = new Playlist(); playlistTemp.id = playlistAllCursor .getLong(playlistAllCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists._ID)); playlistTemp.name = playlistAllCursor .getString(playlistAllCursor.getColumnIndexOrThrow(MediaStore.Audio.Playlists.NAME)); playlistArray.add(playlistTemp); Log.i("PLAYLIST MENU", playlistTemp.id + " " + playlistTemp.name); } // String[] fieldsFrom = new String[1]; // int[] fieldsTo = new int[1]; // fieldsFrom[0] = MediaStore.Audio.Playlists.NAME; // fieldsTo[0] = R.id.playlist_name; // PlaylistCursorAdapter playlistAllAdapter = new PlaylistCursorAdapter(this.getApplicationContext(), // R.layout.playlist_item, // playlistAllCursor, // fieldsFrom, // fieldsTo); PlaylistArrayAdapter playlistAllAdapter = new PlaylistArrayAdapter(getApplicationContext(), R.layout.playlist_item, playlistArray); /* * Create Dialog */ AlertDialog.Builder aD = new AlertDialog.Builder(context); aD.create(); aD.setTitle("Select Playlist"); aD.setAdapter(playlistAllAdapter, playlistDialogClickListener); aD.show(); // playlistView.setAdapter(playlistAllAdapter); // // playlistView.setOnItemClickListener(playlistItemClickListener); // /* // * Animate scroll up of the listview // */ // TranslateAnimation slideUp = new TranslateAnimation(0,0,display.getHeight(),0); // slideUp.setFillAfter(true); // slideUp.setDuration(250); // playlistContainer.startAnimation(slideUp); // //this.mainUIContainer.addView(playlistAllSpinner); return true; /* * Preferences */ case 7: if (GRATIS) { showLitePopup(); return true; } Intent i = new Intent(); i.setClass(getApplicationContext(), RockOnSettings.class); // this.recentPlaylistPeriod = getSharedPreferences(PREFS_NAME, 0) (new RockOnPreferenceManager(FILEX_PREFERENCES_PATH)).getInt(new Constants().PREF_KEY_RECENT_PERIOD, new Constants().RECENT_PERIOD_DEFAULT_IN_DAYS); startActivityForResult(i, new Constants().PREFERENCES_REQUEST); return true; /* * Help */ case 8: this.hideMainUI(); //this.mainUIContainer.setVisibility(View.GONE); this.showHelpUI(); return true; /* * Exit */ case 2: try { this.playerServiceIface.destroy(); this.finish(); } catch (Exception e) { e.printStackTrace(); } return true; } return false; }
From source file:uk.co.droidinactu.ebooklauncher.EBookLauncherActivity.java
private void updateCollectionlist2() { new Thread() { @Override//from w w w .j av a 2 s . com public void run() { setName("updateCollectionlist2()"); try { final String clctname = EditPreferences .getCollectionName2(EBookLauncherActivity.this.getApplication()); if (clctname.equals(EBookLauncherActivity.this.getResources() .getString(R.string.pref_collection_recently_added))) { cursrCollcnts2 = myApp.dataMdl.getRecentlyAdded(EBookLauncherActivity.this); final int nbrItems = cursrCollcnts2.getCount(); if (collection2Start >= nbrItems) { collection2Start = nbrItems - 1; } final String tmpStr; if (collection2Start + 1 < nbrItems) { tmpStr = String.format( EBookLauncherActivity.this .getResources().getString(R.string.page1_nbr_item_format_1), collection2Start + 1, collection2Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF > nbrItems ? nbrItems : collection2Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, nbrItems); } else { tmpStr = String.format(EBookLauncherActivity.this.getResources() .getString(R.string.page1_nbr_item_format_2), collection1Start + 1, nbrItems); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { lblCollection2.setText(clctname + " " + tmpStr); } }); cursrCollcnts2.close(); cursrCollcnts2 = myApp.dataMdl.getRecentlyAdded(EBookLauncherActivity.this, collection2Start, EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF); } else if (clctname.equals(EBookLauncherActivity.this.getResources() .getString(R.string.pref_collection_periodicals))) { cursrCollcnts2 = myApp.dataMdl.getPeriodicals(EBookLauncherActivity.this); final int nbrItems = cursrCollcnts2.getCount(); if (collection2Start >= nbrItems) { collection2Start = nbrItems - 1; } final String tmpStr; if (collection2Start + 1 < nbrItems) { tmpStr = String.format( EBookLauncherActivity.this .getResources().getString(R.string.page1_nbr_item_format_1), collection2Start + 1, collection2Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF > nbrItems ? nbrItems : collection2Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, nbrItems); } else { tmpStr = String.format(EBookLauncherActivity.this.getResources() .getString(R.string.page1_nbr_item_format_2), collection2Start + 1, nbrItems); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { lblCollection2.setText(clctname + " " + tmpStr); } }); cursrCollcnts2.close(); cursrCollcnts2 = myApp.dataMdl.getPeriodicals(EBookLauncherActivity.this, collection2Start, EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF); } else { cursrCollcnts2 = myApp.dataMdl.getBooksInCollection(clctname, BookSortBy.TITLE); final int nbrItems = cursrCollcnts2.getCount(); if (collection2Start >= nbrItems) { collection2Start = nbrItems - 1; } final String tmpStr; if (collection2Start + 1 < nbrItems) { tmpStr = String.format( EBookLauncherActivity.this .getResources().getString(R.string.page1_nbr_item_format_1), collection2Start + 1, collection2Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF > nbrItems ? nbrItems : collection2Start + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, nbrItems); } else { tmpStr = String.format(EBookLauncherActivity.this.getResources() .getString(R.string.page1_nbr_item_format_2), collection2Start + 1, nbrItems); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { lblCollection2.setText(clctname + " " + tmpStr); } }); cursrCollcnts2.close(); cursrCollcnts2 = myApp.dataMdl.getBooksInCollection(clctname, collection2Start, EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, BookSortBy.TITLE); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { if (EditPreferences.useFilenames(EBookLauncherActivity.this)) { listAdapterCollectns2 = new SimpleCursorAdapter(EBookLauncherActivity.this, R.layout.book_grid_item_filename, cursrCollcnts2, DeviceFactory.getBookColumnsToMap(true), BooksActivity.bookGridColsMapToFilename); } else { int layoutId = R.layout.book_grid_item; if (android.os.Build.MANUFACTURER .equalsIgnoreCase(DeviceFactory.DEVICE_MANUFACTURER_BARNES_AND_NOBLE)) { layoutId = R.layout.book_grid_item_nook; } listAdapterCollectns2 = new SimpleCursorAdapter(EBookLauncherActivity.this, layoutId, cursrCollcnts2, DeviceFactory.getBookColumnsToMap(false), BooksActivity.bookGridColsMapTo); } EBookLauncherActivity.this.setupList(listviewCollectns2, listAdapterCollectns2, cursrCollcnts2); } }); } catch (final Exception e) { Log.e(EBookLauncherApplication.LOG_TAG, EBookLauncherActivity.LOG_TAG + "Exception ", e); } } }.start(); }
From source file:uk.co.droidinactu.ebooklauncher.EBookLauncherActivity.java
/** * this method populates the "Currently Reading" list. *///from www . jav a2 s .c o m private void updateCurrentlyReading() { new Thread() { @Override public void run() { setName("updateCurrentlyReading()"); try { cursrCurrentRead = myApp.dataMdl .getCurrentlyReading(EBookLauncherActivity.this.getApplication()); final int nbrItems = cursrCurrentRead.getCount(); if (currentlyReadingStart >= nbrItems) { currentlyReadingStart = nbrItems - 1; } final String tmpStr; if (currentlyReadingStart + 1 < nbrItems) { tmpStr = String.format( EBookLauncherActivity.this .getResources().getString(R.string.page1_nbr_item_format_1), currentlyReadingStart + 1, currentlyReadingStart + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF > nbrItems ? nbrItems : currentlyReadingStart + EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, nbrItems); } else { tmpStr = String.format(EBookLauncherActivity.this.getResources() .getString(R.string.page1_nbr_item_format_2), currentlyReadingStart + 1, nbrItems); } EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { lblCurrentRead.setText(EBookLauncherActivity.this.getResources() .getString(R.string.page1_currently_reading_lbl) + " " + tmpStr); } }); cursrCurrentRead.close(); cursrCurrentRead = myApp.dataMdl.getCurrentlyReading( EBookLauncherActivity.this.getApplication(), currentlyReadingStart, EBookLauncherActivity.NUMBER_BOOKS_ON_SHELF, null); EBookLauncherActivity.this.runOnUiThread(new Runnable() { @Override public void run() { if (EditPreferences.useFilenames(EBookLauncherActivity.this)) { listAdapterCurrentRead = new SimpleCursorAdapter(EBookLauncherActivity.this, R.layout.book_grid_item_filename, cursrCurrentRead, DeviceFactory.getBookColumnsToMap(true), BooksActivity.bookGridColsMapToFilename); } else { listAdapterCurrentRead = new SimpleCursorAdapter(EBookLauncherActivity.this, DeviceFactory.getBookGridItemLayout(), cursrCurrentRead, DeviceFactory.getBookColumnsToMap(false), BooksActivity.bookGridColsMapTo); } EBookLauncherActivity.this.setupList(listviewCurrentRead, listAdapterCurrentRead, cursrCurrentRead); } }); } catch (final Exception e) { Log.e(EBookLauncherApplication.LOG_TAG, EBookLauncherActivity.LOG_TAG + "Exception ", e); } } }.start(); }