use of com.ichi2.anki.CardBrowser.Column.CREATED in project AnkiChinaAndroid by ankichinateam.
the class VideoPlayer method onCreate.
/**
* Called when the activity is first created.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
Timber.i("onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);
mPath = getIntent().getStringExtra("path");
Timber.i("Video Player intent had path: %s", mPath);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mVideoView = findViewById(R.id.video_surface);
mVideoView.getHolder().addCallback(this);
mSoundPlayer = new Sound();
}
use of com.ichi2.anki.CardBrowser.Column.CREATED in project AnkiChinaAndroid by ankichinateam.
the class Sched method _updateCutoff.
/**
* Daily cutoff ************************************************************* **********************************
* This function uses GregorianCalendar so as to be sensitive to leap years, daylight savings, etc.
*/
@Override
public void _updateCutoff() {
Integer oldToday = mToday;
// days since col created
mToday = (int) ((getTime().intTime() - mCol.getCrt()) / SECONDS_PER_DAY);
// end of day cutoff
mDayCutoff = mCol.getCrt() + ((mToday + 1) * SECONDS_PER_DAY);
if (oldToday != mToday) {
mCol.log(mToday, mDayCutoff);
}
// instead
for (Deck deck : mCol.getDecks().all()) {
update(deck);
}
// unbury if the day has rolled over
int unburied = mCol.getConf().optInt("lastUnburied", 0);
if (unburied < mToday) {
SyncStatus.ignoreDatabaseModification(this::unburyCards);
}
}
use of com.ichi2.anki.CardBrowser.Column.CREATED in project AnkiChinaAndroid by ankichinateam.
the class SchedV2 method _updateCutoff.
/**
* Daily cutoff ************************************************************* **********************************
* This function uses GregorianCalendar so as to be sensitive to leap years, daylight savings, etc.
*/
/* Overriden: other way to count time*/
public void _updateCutoff() {
Integer oldToday = mToday == null ? 0 : mToday;
// days since col created
mToday = _daysSinceCreation();
// end of day cutoff
mDayCutoff = _dayCutoff();
if (oldToday != mToday) {
mCol.log(mToday, mDayCutoff);
}
// instead
for (Deck deck : mCol.getDecks().all()) {
update(deck);
}
// unbury if the day has rolled over
int unburied = mCol.getConf().optInt("lastUnburied", 0);
if (unburied < mToday) {
SyncStatus.ignoreDatabaseModification(this::unburyCards);
mCol.getConf().put("lastUnburied", mToday);
}
}
use of com.ichi2.anki.CardBrowser.Column.CREATED in project Anki-Android by ankidroid.
the class DeckPicker method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Resources res = getResources();
if (getDrawerToggle().onOptionsItemSelected(item)) {
return true;
}
int itemId = item.getItemId();
if (itemId == R.id.action_undo) {
Timber.i("DeckPicker:: Undo button pressed");
undo();
return true;
} else if (itemId == R.id.action_sync) {
Timber.i("DeckPicker:: Sync button pressed");
sync();
return true;
} else if (itemId == R.id.action_import) {
Timber.i("DeckPicker:: Import button pressed");
showDialogFragment(ImportFileSelectionFragment.createInstance(this));
return true;
} else if (itemId == R.id.action_new_filtered_deck) {
CreateDeckDialog createFilteredDeckDialog = new CreateDeckDialog(DeckPicker.this, R.string.new_deck, CreateDeckDialog.DeckDialogType.FILTERED_DECK, null);
createFilteredDeckDialog.setOnNewDeckCreated((id) -> {
// a filtered deck was created
openStudyOptions(true);
});
createFilteredDeckDialog.showFilteredDeckDialog();
return true;
} else if (itemId == R.id.action_check_database) {
Timber.i("DeckPicker:: Check database button pressed");
showDatabaseErrorDialog(DatabaseErrorDialog.DIALOG_CONFIRM_DATABASE_CHECK);
return true;
} else if (itemId == R.id.action_check_media) {
Timber.i("DeckPicker:: Check media button pressed");
showMediaCheckDialog(MediaCheckDialog.DIALOG_CONFIRM_MEDIA_CHECK);
return true;
} else if (itemId == R.id.action_empty_cards) {
Timber.i("DeckPicker:: Empty cards button pressed");
handleEmptyCards();
return true;
} else if (itemId == R.id.action_model_browser_open) {
Timber.i("DeckPicker:: Model browser button pressed");
Intent noteTypeBrowser = new Intent(this, ModelBrowser.class);
startActivityForResultWithAnimation(noteTypeBrowser, 0, START);
return true;
} else if (itemId == R.id.action_restore_backup) {
Timber.i("DeckPicker:: Restore from backup button pressed");
showDatabaseErrorDialog(DatabaseErrorDialog.DIALOG_CONFIRM_RESTORE_BACKUP);
return true;
} else if (itemId == R.id.action_export) {
Timber.i("DeckPicker:: Export collection button pressed");
String msg = getResources().getString(R.string.confirm_apkg_export);
mExportingDelegate.showExportDialog(msg);
return true;
}
return super.onOptionsItemSelected(item);
}
use of com.ichi2.anki.CardBrowser.Column.CREATED in project Anki-Android by ankidroid.
the class DeckPicker method onCreate.
// ----------------------------------------------------------------------------
// ANDROID ACTIVITY METHODS
// ----------------------------------------------------------------------------
/**
* Called when the activity is first created.
*/
@Override
protected void onCreate(Bundle savedInstanceState) throws SQLException {
if (showedActivityFailedScreen(savedInstanceState)) {
return;
}
Timber.d("onCreate()");
mExportingDelegate = new ActivityExportingDelegate(this, this::getCol);
mCustomStudyDialogFactory = new CustomStudyDialogFactory(this::getCol, this).attachToActivity(this);
mContextMenuFactory = new DeckPickerContextMenu.Factory(this::getCol).attachToActivity(this);
// we need to restore here, as we need it before super.onCreate() is called.
restoreWelcomeMessage(savedInstanceState);
// Then set theme and content view
super.onCreate(savedInstanceState);
handleStartup();
setContentView(R.layout.homescreen);
View mainView = findViewById(android.R.id.content);
// check, if tablet layout
mStudyoptionsFrame = findViewById(R.id.studyoptions_fragment);
// set protected variable from NavigationDrawerActivity
mFragmented = mStudyoptionsFrame != null && mStudyoptionsFrame.getVisibility() == View.VISIBLE;
// Open StudyOptionsFragment if in fragmented mode
if (mFragmented && !mStartupError) {
loadStudyOptionsFragment(false);
}
registerExternalStorageListener();
// create inherited navigation drawer layout here so that it can be used by parent class
initNavigationDrawer(mainView);
setTitle(getResources().getString(R.string.app_name));
mDeckPickerContent = findViewById(R.id.deck_picker_content);
mRecyclerView = findViewById(R.id.files);
mNoDecksPlaceholder = findViewById(R.id.no_decks_placeholder);
mDeckPickerContent.setVisibility(View.GONE);
mNoDecksPlaceholder.setVisibility(View.GONE);
// specify a LinearLayoutManager and set up item dividers for the RecyclerView
mRecyclerViewLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mRecyclerViewLayoutManager);
TypedArray ta = this.obtainStyledAttributes(new int[] { R.attr.deckDivider });
Drawable divider = ta.getDrawable(0);
ta.recycle();
DividerItemDecoration dividerDecorator = new DividerItemDecoration(this, mRecyclerViewLayoutManager.getOrientation());
dividerDecorator.setDrawable(divider);
mRecyclerView.addItemDecoration(dividerDecorator);
// Add background to Deckpicker activity
View view = mFragmented ? findViewById(R.id.deckpicker_xl_view) : findViewById(R.id.root_layout);
boolean hasDeckPickerBackground = false;
try {
hasDeckPickerBackground = applyDeckPickerBackground(view);
} catch (OutOfMemoryError e) {
// 6608 - OOM should be catchable here.
Timber.w(e, "Failed to apply background - OOM");
UIUtils.showThemedToast(this, getString(R.string.background_image_too_large), false);
} catch (Exception e) {
Timber.w(e, "Failed to apply background");
UIUtils.showThemedToast(this, getString(R.string.failed_to_apply_background_image, e.getLocalizedMessage()), false);
}
// create and set an adapter for the RecyclerView
mDeckListAdapter = new DeckAdapter(getLayoutInflater(), this);
mDeckListAdapter.setDeckClickListener(mDeckClickListener);
mDeckListAdapter.setCountsClickListener(mCountsClickListener);
mDeckListAdapter.setDeckExpanderClickListener(mDeckExpanderClickListener);
mDeckListAdapter.setDeckLongClickListener(mDeckLongClickListener);
mDeckListAdapter.enablePartialTransparencyForBackground(hasDeckPickerBackground);
mRecyclerView.setAdapter(mDeckListAdapter);
mPullToSyncWrapper = findViewById(R.id.pull_to_sync_wrapper);
mPullToSyncWrapper.setDistanceToTriggerSync(SWIPE_TO_SYNC_TRIGGER_DISTANCE);
mPullToSyncWrapper.setOnRefreshListener(() -> {
Timber.i("Pull to Sync: Syncing");
mPullToSyncWrapper.setRefreshing(false);
sync();
});
mPullToSyncWrapper.getViewTreeObserver().addOnScrollChangedListener(() -> mPullToSyncWrapper.setEnabled(mRecyclerViewLayoutManager.findFirstCompletelyVisibleItemPosition() == 0));
// Setup the FloatingActionButtons, should work everywhere with min API >= 15
mFloatingActionMenu = new DeckPickerFloatingActionMenu(view, this);
mReviewSummaryTextView = findViewById(R.id.today_stats_text_view);
mShortAnimDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
new Onboarding.DeckPicker(this, mRecyclerViewLayoutManager).onCreate();
}
Aggregations