use of com.ichi2.anki.export.ActivityExportingDelegate 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