android.support.v4.widget.CursorAdapter Java Examples

The following examples show how to use android.support.v4.widget.CursorAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomCommandActivity.java    From rpicheck with MIT License 6 votes vote down vote up
/**
 * Init ListView with commands.
 *
 * @param pi
 */
private void initListView(RaspberryDeviceBean pi) {
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            fullCommandCursor = deviceDb.getFullCommandCursor();
            return null;
        }

        @Override
        protected void onPostExecute(Void r) {
            CommandAdapter commandsAdapter = new CommandAdapter(CustomCommandActivity.this, fullCommandCursor, CursorAdapter.FLAG_AUTO_REQUERY);
            commandListView.setAdapter(commandsAdapter);
            commandListView.setOnItemClickListener(CustomCommandActivity.this);
            // commandListView.setOnItemLongClickListener(CustomCommandActivity.this);
            registerForContextMenu(commandListView);
        }
    }.execute();

}
 
Example #2
Source File: ManageDownloadsActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
	if (ACTION_LIBRARY_UPDATE.equals(intent.getAction())) {
		Log.d(LOG_TAG, "library update broadcast received");
		// TODO
	} else if (ACTION_BADGE_EARNED.equals(intent.getAction()) && dataService != null) {
		Badge badge = (Badge) intent.getSerializableExtra(EXTRA_BADGE);
		dataService.getAPIAdapter().toastBadge(badge);
	} else if (Constants.ACTION_OFFLINE_VIDEO_SET_CHANGED.equals(intent.getAction())) {
		((CursorAdapter) gridView.getAdapter()).changeCursor(getCursor());
		setCancelButtonEnabled(areDownloadsEnqueued());
		setupListNavigation();
	} else if (ACTION_DOWNLOAD_PROGRESS_UPDATE.equals(intent.getAction())) {
		@SuppressWarnings("unchecked")
		Map<String, Integer> status = (Map<String, Integer>) intent.getSerializableExtra(EXTRA_STATUS);
		Adapter adapter = (Adapter) gridView.getAdapter();
		adapter.setCurrentDownloadStatus(status);
		adapter.updateBars();
	} else if (ACTION_TOAST.equals(intent.getAction())) {
		Toast.makeText(ManageDownloadsActivity.this, intent.getStringExtra(EXTRA_MESSAGE), Toast.LENGTH_SHORT).show();
	}
}
 
Example #3
Source File: RecycleActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 6 votes vote down vote up
private void deleteAll(){
    ListView notesList = (ListView) findViewById(R.id.notes_list);
    CursorAdapter ca = (CursorAdapter) notesList.getAdapter();
    Cursor c = ca.getCursor();
    c.moveToPosition(-1);
    while (c.moveToNext()){
        if (c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_TYPE)) == DbContract.NoteEntry.TYPE_AUDIO) {
            String filePath = getFilesDir().getPath()+"/audio_notes" + c.getString(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_CONTENT));
            new File(filePath).delete();
        } else if (c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_TYPE)) == DbContract.NoteEntry.TYPE_SKETCH) {
            String content = c.getString(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_CONTENT));
            new File(getFilesDir().getPath()+"/sketches"+content).delete();
            new File(getFilesDir().getPath()+"/sketches"+content.substring(0, content.length()-3) + "jpg").delete();
        }
        DbAccess.deleteNote(getBaseContext(), c.getInt(c.getColumnIndexOrThrow(DbContract.NoteEntry.COLUMN_ID)));
    }
    updateList();
}
 
Example #4
Source File: RecycleActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 5 votes vote down vote up
private void updateList() {
    ListView notesList = (ListView) findViewById(R.id.notes_list);
    CursorAdapter adapter = (CursorAdapter) notesList.getAdapter();
    String selection = DbContract.NoteEntry.COLUMN_TRASH + " = ?";
    String[] selectionArgs = { "1" };
    adapter.changeCursor(DbAccess.getCursorAllNotes(getBaseContext(), selection, selectionArgs));
}
 
Example #5
Source File: ArcaSimpleAdapterSupportFragment.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public CursorAdapter onCreateAdapter(final AdapterView<CursorAdapter> adapterView, final Bundle savedInstanceState) {
    final int layout = FragmentUtils.getAdapterItemLayout(this.getClass());
    final Collection<Binding> bindings = FragmentUtils.getBindings(this.getClass());
    final SupportCursorAdapter adapter = new SupportCursorAdapter(getActivity(), layout, bindings);
    adapter.setViewBinder(FragmentUtils.createViewBinder(this.getClass()));
    return adapter;
}
 
Example #6
Source File: ArcaAdapterSupportFragment.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void setupAdapterView(final View view, final Bundle savedInstanceState) {
       mAdapterView = (AdapterView<CursorAdapter>) view.findViewById(getAdapterViewId());

       mAdapter = onCreateAdapter(mAdapterView, savedInstanceState);

       mAdapterView.setAdapter(mAdapter);
}
 
Example #7
Source File: ArcaSimpleItemSupportFragment.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public CursorAdapter onCreateAdapter(final View view, final Bundle savedInstanceState) {
    final Collection<Binding> bindings = FragmentUtils.getBindings(this.getClass());
    final SupportItemAdapter adapter = new SupportItemAdapter(getActivity(), bindings);
    adapter.setViewBinder(FragmentUtils.createViewBinder(this.getClass()));
    return adapter;
}
 
Example #8
Source File: ArcaItemSupportFragment.java    From arca-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void bindViewAtPosition(final int position) {
	final CursorAdapter adapter = getCursorAdapter();
	final Cursor cursor = adapter.getCursor();
	if (cursor != null && cursor.moveToPosition(position)) {
		adapter.bindView(getView(), getActivity(), cursor);
	}
}
 
Example #9
Source File: RecipeItemListActivity.java    From android-recipes-app with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onSuggestionClick(int position) {
	CursorAdapter selectedView = searchView.getSuggestionsAdapter();
	Cursor cursor = (Cursor) selectedView.getItem(position);
	int index = cursor.getColumnIndexOrThrow(SearchManager.SUGGEST_COLUMN_TEXT_1);
	searchView.setQuery(cursor.getString(index), true);
	return true;
}
 
Example #10
Source File: DeviceSpinnerAdapter.java    From rpicheck with MIT License 5 votes vote down vote up
/**
 * @param context the Context
 * @param c full device cursor
 * @param alwaysWithUserHost true, if user@host should always be displayed (not only in dropdown view)
 */
public DeviceSpinnerAdapter(Context context, Cursor c, boolean alwaysWithUserHost) {
    super(context, alwaysWithUserHost ? R.layout.device_row_dropdown : R.layout.device_row,
            c, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    this.inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
 
Example #11
Source File: VideoListActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 5 votes vote down vote up
private void resetListContents(String topicId) {
   	Log.d(LOG_TAG, "resetListContents");
   	
   	if (topicId != null) {
    	// Set this.topicCursor to a cursor over the videos we need.
    	User user = dataService.getAPIAdapter().getCurrentUser();
    	String userId = user == null ? "" : user.getNickname();
    	
    	String sql = "select video._id, video.youtube_id, video.readable_id, video.title " +
			    			", uservideo.seconds_watched, uservideo.completed " +
    			"from topicvideo, video " +
    			"left outer join uservideo on uservideo.video_id = video.readable_id and uservideo.user_id=? " +
    			"where topicvideo.topic_id=? and topicvideo.video_id=video.readable_id ";
    	
    	String[] selectionArgs;
    	if (isShowingDownloadedVideosOnly()) {
    		sql += " and video.download_status=? ";
    		selectionArgs = new String[] {userId, topicId, String.valueOf(Video.DL_STATUS_COMPLETE)};
    	} else {
    		selectionArgs = new String[] {userId, topicId};
    	}
    	sql += "order by video.seq";
    	
		if (topicCursor != null) {
			topicCursor.close();
		}
    	topicCursor = this.dataService.getHelper().getReadableDatabase()
    			.rawQuery(sql, selectionArgs);
    	
    	CursorAdapter adapter = getUnwrappedAdapter();
    	if (adapter != null) {
	    	adapter.changeCursor(topicCursor);
    	}
   	}
}
 
Example #12
Source File: ManageCategoriesActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 5 votes vote down vote up
private void deleteSelectedItems(){
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    boolean delNotes = sp.getBoolean(SettingsActivity.PREF_DEL_NOTES, false);
    CursorAdapter adapter = (CursorAdapter) list.getAdapter();
    SparseBooleanArray checkedItemPositions = list.getCheckedItemPositions();
    for (int i=0; i < checkedItemPositions.size(); i++) {
        if(checkedItemPositions.valueAt(i)) {
            if (delNotes) {
                DbAccess.trashNotesByCategoryId(getBaseContext(), (int) (long) adapter.getItemId(checkedItemPositions.keyAt(i)));
            }
            DbAccess.deleteCategory(getBaseContext(), (int) (long) adapter.getItemId(checkedItemPositions.keyAt(i)));
        }
    }
}
 
Example #13
Source File: ManageCategoriesActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 5 votes vote down vote up
private void deleteItem(int position) {
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    boolean delNotes = sp.getBoolean(SettingsActivity.PREF_DEL_NOTES, false);
    CursorAdapter adapter = (CursorAdapter) list.getAdapter();
    if (delNotes) {
        DbAccess.trashNotesByCategoryId(getBaseContext(), (int) (long) adapter.getItemId(position));
    }
    DbAccess.deleteCategory(getBaseContext(), (int) (long) adapter.getItemId(position));
    updateList();
}
 
Example #14
Source File: MainActivity.java    From privacy-friendly-notes with GNU General Public License v3.0 5 votes vote down vote up
private void deleteSelectedItems(){
    ListView notesList = (ListView) findViewById(R.id.notes_list);
    CursorAdapter adapter = (CursorAdapter) notesList.getAdapter();
    SparseBooleanArray checkedItemPositions = notesList.getCheckedItemPositions();
    for (int i=0; i < checkedItemPositions.size(); i++) {
        if(checkedItemPositions.valueAt(i)) {
            DbAccess.trashNote(getBaseContext(), (int) (long) adapter.getItemId(checkedItemPositions.keyAt(i)));
        }
    }
}
 
Example #15
Source File: LogcatActivity.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_logcat);

    LogLine.isScrubberEnabled = PreferenceHelper.isScrubberEnabled(this);

    handleShortcuts(getIntent().getStringExtra("shortcut_action"));

    mHandler = new Handler(Looper.getMainLooper());

    binding.fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogHelper.stopRecordingLog(LogcatActivity.this);
        }
    });

    binding.list.setLayoutManager(new LinearLayoutManager(this));

    binding.list.setItemAnimator(null);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_actionbar));
    setTitle(R.string.logcat);

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(this);

    log.d("initial collapsed mode is %s", mCollapsedMode);

    mSearchSuggestionsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_dropdown,
            null,
            new String[]{"suggestion"},
            new int[]{android.R.id.text1},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setUpAdapter();
    updateBackgroundColor();
    runUpdatesIfNecessaryAndShowWelcomeMessage();
}
 
Example #16
Source File: VideosFragment.java    From video-player with MIT License 5 votes vote down vote up
private void requestPermissions(final Activity thisActivity, View videosFragmentView) {
    if (ContextCompat.checkSelfPermission(thisActivity,
            Manifest.permission.READ_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED) {
        // Should we show an explanation?
        if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
                Manifest.permission.READ_EXTERNAL_STORAGE)) {
            // Show an explanation to the user *asynchronously* -- don't block
            // this thread waiting for the user's response! After the user
            // sees the explanation, try again to request the permission.
            MainActivity.permissionsSnackbar = Snackbar.make(videosFragmentView, "Storage access permission is required to scan and play media files on this device.", Snackbar.LENGTH_INDEFINITE)
                    .setAction("OK", new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            ActivityCompat.requestPermissions(thisActivity,
                                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                                    MainActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
                        }
                    });
            MainActivity.permissionsSnackbar.show();

        } else {
            // No explanation needed, we can request the permission.
            ActivityCompat.requestPermissions(thisActivity,
                    new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                    MainActivity.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
            // MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE is an
            // app-defined int constant. The callback method gets the
            // result of the request.
        }
    } else {
        Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
        String[] projection = {MediaStore.Video.VideoColumns.DISPLAY_NAME, MediaStore.Video.VideoColumns.DATA, MediaStore.Video.VideoColumns._ID};
        Cursor c = getActivity().getContentResolver().query(uri, projection, null, null, null);
        mAdapter = new VideosAdapter(getActivity(), c, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    }
}
 
Example #17
Source File: SearchViewAssert.java    From assertj-android with Apache License 2.0 5 votes vote down vote up
public SearchViewAssert hasSuggestionsAdapter(CursorAdapter adapter) {
  isNotNull();
  CursorAdapter actualAdapter = actual.getSuggestionsAdapter();
  assertThat(actualAdapter) //
      .overridingErrorMessage("Expected suggestions adapter <%s> but was <%s>.", adapter,
          actualAdapter) //
      .isSameAs(adapter);
  return this;
}
 
Example #18
Source File: LogcatActivity.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_logcat);

    LogLine.isScrubberEnabled = PreferenceHelper.isScrubberEnabled(this);

    handleShortcuts(getIntent().getStringExtra("shortcut_action"));

    mHandler = new Handler(Looper.getMainLooper());

    binding.fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogHelper.stopRecordingLog(LogcatActivity.this);
        }
    });

    binding.list.setLayoutManager(new LinearLayoutManager(this));

    binding.list.setItemAnimator(null);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_actionbar));
    setTitle(R.string.logcat);

    mCollapsedMode = !PreferenceHelper.getExpandedByDefaultPreference(this);

    log.d("initial collapsed mode is %s", mCollapsedMode);

    mSearchSuggestionsAdapter = new SimpleCursorAdapter(this,
            R.layout.list_item_dropdown,
            null,
            new String[]{"suggestion"},
            new int[]{android.R.id.text1},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);

    setUpAdapter();
    updateBackgroundColor();
    runUpdatesIfNecessaryAndShowWelcomeMessage();
}
 
Example #19
Source File: CalendarSelectionView.java    From ToDay with MIT License 5 votes vote down vote up
public CalendarCursorAdapter(Context context) {
    super(context,
            R.layout.list_item_calendar,
            null,
            new String[]{CalendarContract.Calendars.CALENDAR_DISPLAY_NAME},
            new int[]{R.id.text_view_title},
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
}
 
Example #20
Source File: CreateTicketActivity.java    From faveo-helpdesk-android-app with Open Software License 3.0 5 votes vote down vote up
/**
 * Setting up the views here.
 */
public void setUpViews() {
    final CursorAdapter suggestionAdapter = new SimpleCursorAdapter(this,
            android.R.layout.simple_list_item_1,
            null,
            new String[]{SearchManager.SUGGEST_COLUMN_TEXT_1},
            new int[]{android.R.id.text1},
            0);
    final List<String> suggestions = new ArrayList<>();

    spinnerHelpArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, helptopicItems); //selected item will look like a spinner set from XML
    spinnerHelpArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerHelpTopic.setAdapter(spinnerHelpArrayAdapter);

    spinnerSLAAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item,slaItems); //selected item will look like a spinner set from XML
    spinnerSLAAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerSLA.setAdapter(spinnerSLAAdapter);


    spinnerPriArrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, priorityItems); //selected item will look like a spinner set from XML
    spinnerPriArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerPriority.setAdapter(spinnerPriArrayAdapter);

    editTextLastName.setFilters(new InputFilter[]{filter});
    editTextFirstName.setFilters(new InputFilter[]{filter});
    subEdittext.setFilters(new InputFilter[]{filter});


}
 
Example #21
Source File: MainActivity.java    From openshop.io-android with MIT License 5 votes vote down vote up
@Override
public void prepareSearchSuggestions(List<DrawerItemCategory> navigation) {
    final String[] from = new String[]{"categories"};
    final int[] to = new int[]{android.R.id.text1};

    searchSuggestionsAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1,
            null, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    if (navigation != null && !navigation.isEmpty()) {
        for (int i = 0; i < navigation.size(); i++) {
            if (!searchSuggestionsList.contains(navigation.get(i).getName())) {
                searchSuggestionsList.add(navigation.get(i).getName());
            }

            if (navigation.get(i).hasChildren()) {
                for (int j = 0; j < navigation.get(i).getChildren().size(); j++) {
                    if (!searchSuggestionsList.contains(navigation.get(i).getChildren().get(j).getName())) {
                        searchSuggestionsList.add(navigation.get(i).getChildren().get(j).getName());
                    }
                }
            }
        }
        searchSuggestionsAdapter.notifyDataSetChanged();
    } else {
        Timber.e("Search suggestions loading failed.");
        searchSuggestionsAdapter = null;
    }
}
 
Example #22
Source File: ManageDownloadsActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 4 votes vote down vote up
public Renderer(android.support.v4.widget.CursorAdapter adapter,
		ThumbnailManager thumbnailManager, int cacheCapacity) {
	super(2, R.id.thumbnail, thumbnailManager, Thumbnail.QUALITY_MEDIUM, cacheCapacity);
	mAdapter = adapter;
}
 
Example #23
Source File: ArcaItemSupportFragment.java    From arca-android with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public CursorAdapter getCursorAdapter() {
	return mAdapter;
}
 
Example #24
Source File: LocalPhotosGridFragment.java    From glimmr with Apache License 2.0 4 votes vote down vote up
public MediaStoreImagesAdapter(Context context, int layout, Cursor c,
        String[] from, int[] to) {
    super(context, layout, c, from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
    mCursor = c;
}
 
Example #25
Source File: AdapterViewFragment.java    From COCOFramework with Apache License 2.0 4 votes vote down vote up
public CursorAdapter getAdapter() {
    return mAdapter;
}
 
Example #26
Source File: ManageDownloadsActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 4 votes vote down vote up
private CursorAdapter getDisplayOptionsAdapter(Cursor c) {
	String[] from = {"title"};
	int[] to = {android.R.id.text1};
	return new SimpleCursorAdapter(getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, c, from, to, 0);
}
 
Example #27
Source File: StartActivity.java    From EverMemo with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	getSupportActionBar().setLogo(R.drawable.ab_logo);
	mContext = this;
	mEvernote = new Evernote(mContext);
	MobclickAgent.onError(this);
	setContentView(R.layout.activity_start);
	mMemosGrid = (MultiColumnListView) findViewById(R.id.memos);
	mBindEvernotePanel = (LinearLayout) findViewById(R.id.evernote_panel);
	mBindEvernote = (Button) findViewById(R.id.bind_evernote);
	mBindEvernotePandelHeight = mBindEvernotePanel.getLayoutParams().height;

	LoaderManager manager = getSupportLoaderManager();
	mMemosAdapter = new MemosAdapter(mContext, null,
			CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER, this, this);
	mMemosGrid.setAdapter(mMemosAdapter);

	manager.initLoader(1, null, this);
	mSharedPreferences = PreferenceManager
			.getDefaultSharedPreferences(mContext);

	if (mSharedPreferences.getInt(sStartCount, 1) == 1) {
		mBindEvernotePanel.startAnimation(new MarginAnimation(
				mBindEvernotePanel, 0, 0, 0, 0, 600));
		new Timer().schedule(new TimerTask() {

			@Override
			public void run() {

				StartActivity.this.runOnUiThread(new Runnable() {

					@Override
					public void run() {
						mBindEvernotePanel
								.startAnimation(new MarginAnimation(
										mBindEvernotePanel, 0, 0, 0,
										-mBindEvernotePandelHeight));
					}
				});
			}
		}, 5000);
		mSharedPreferences
				.edit()
				.putInt(sStartCount,
						mSharedPreferences.getInt(sStartCount, 1) + 1)
				.commit();
		mBindEvernote.setOnClickListener(this);
	}

	if (mSharedPreferences.getBoolean(
			SettingActivity.OPEN_MEMO_WHEN_START_UP, false)) {
		startActivity(new Intent(this, MemoActivity.class));
	}

	mEvernote.sync(true, true, null);
	UmengUpdateAgent.update(this);
}
 
Example #28
Source File: ManageDownloadsActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onStart() {
	super.onStart();
	
	gridView = (GridView) findViewById(R.id.grid);
	gridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
	gridView.setMultiChoiceModeListener(multiChoiceModeListener);
	gridView.setOnItemClickListener(itemClickListener);
	
	View emptyView = getLayoutInflater().inflate(R.layout.listview_empty, null, false);
	((TextView) emptyView.findViewById(R.id.text_list_empty)).setText(R.string.msg_no_downloaded_videos);
	ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
	addContentView(emptyView, p);
	
	gridView.setEmptyView(emptyView);
	
	requestDataService(new ObjectCallback<KADataService>() {
		@Override
		public void call(final KADataService dataService) {
			ManageDownloadsActivity.this.dataService = dataService;
			
			CursorAdapter adapter = new Adapter(ManageDownloadsActivity.this, null, 0, dataService.getThumbnailManager());
			gridView.setAdapter(adapter);

			new AsyncTask<Void, Void, Cursor>() {
				@Override
				protected Cursor doInBackground(Void... arg) {
					return getCursor();
				}
				
				@Override
				protected void onPostExecute(Cursor cursor) {
					((CursorAdapter) gridView.getAdapter()).changeCursor(cursor);
				}
			}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
			
			final ActionBar ab = getActionBar();
			ab.setDisplayHomeAsUpEnabled(true);
			
			ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
			ab.setTitle("");
			
			setupListNavigation();
			
			// The receiver performs actions that require a dataService, so register it here.
			IntentFilter filter = new IntentFilter();
			filter.addAction(ACTION_LIBRARY_UPDATE);
			filter.addAction(ACTION_BADGE_EARNED);
			filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED);
			filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE);
			filter.addAction(ACTION_TOAST);
			broadcastManager.registerReceiver(receiver, filter);
		}
	});
}
 
Example #29
Source File: TopicListActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 4 votes vote down vote up
public Renderer(CursorAdapter adapter, ThumbnailManager thumbnailManager, int cacheCapacity) {
	super(2, R.id.pane_topic_image, thumbnailManager, Thumbnail.QUALITY_SD, cacheCapacity);
	mAdapter = adapter;
}
 
Example #30
Source File: VideoListActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 4 votes vote down vote up
public Renderer(android.support.v4.widget.CursorAdapter adapter,
		ThumbnailManager thumbnailManager, int cacheCapacity) {
	super(2, R.id.thumbnail, thumbnailManager, Thumbnail.QUALITY_HIGH, cacheCapacity);
	mAdapter = adapter;
}