Search in sources :

Example 1 with FixedTextView

use of com.ichi2.ui.FixedTextView in project Anki-Android by ankidroid.

the class Statistics method onCollectionLoaded.

@Override
protected void onCollectionLoaded(Collection col) {
    Timber.d("onCollectionLoaded()");
    super.onCollectionLoaded(col);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    // Set up the ViewPager with the sections adapter.
    mViewPager = findViewById(R.id.pager);
    mViewPager.setAdapter(new Statistics.StatsPagerAdapter((this)));
    mViewPager.setOffscreenPageLimit(8);
    mSlidingTabLayout = findViewById(R.id.sliding_tabs);
    // Fixes #8984: scroll to position 0 in RTL layouts
    ViewTreeObserver tabObserver = mSlidingTabLayout.getViewTreeObserver();
    tabObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        // Note: we can't use a lambda as we use 'this' to refer to the class.
        @Override
        public void onGlobalLayout() {
            // we need this here: If we select tab 0 before in an RTL context the layout has been drawn,
            // then it doesn't perform a scroll animation and selects the wrong element
            mSlidingTabLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            mSlidingTabLayout.selectTab(mSlidingTabLayout.getTabAt(0));
        }
    });
    // Setup Task Handler
    mTaskHandler = AnkiStatsTaskHandler.getInstance(col);
    // Dirty way to get text size from a TextView with current style, change if possible
    float size = new FixedTextView(this).getTextSize();
    mTaskHandler.setmStandardTextSize(size);
    // Prepare options menu only after loading everything
    supportInvalidateOptionsMenu();
    // StatisticFragment.updateAllFragments();
    String defaultDeck = AnkiDroidApp.getSharedPrefs(this).getString("stats_default_deck", "current");
    switch(defaultDeck) {
        case "current":
            mStatsDeckId = getCol().getDecks().selected();
            break;
        case "all":
            mStatsDeckId = Stats.ALL_DECKS_ID;
            break;
        default:
            Timber.w("Unknown defaultDeck: %s", defaultDeck);
            break;
    }
    mDeckSpinnerSelection = new DeckSpinnerSelection(this, col, this.findViewById(R.id.toolbar_spinner), true, true);
    mDeckSpinnerSelection.initializeActionBarDeckSpinner(this.getSupportActionBar());
    mDeckSpinnerSelection.selectDeckById(mStatsDeckId, false);
    mTaskHandler.setDeckId(mStatsDeckId);
    mViewPager.getAdapter().notifyDataSetChanged();
}
Also used : FixedTextView(com.ichi2.ui.FixedTextView) ViewTreeObserver(android.view.ViewTreeObserver)

Example 2 with FixedTextView

use of com.ichi2.ui.FixedTextView in project Anki-Android by ankidroid.

the class BasicAudioRecordingFieldController method addFieldPreview.

private void addFieldPreview(Context context, LinearLayout layout) {
    // add preview of the field data to provide context to the user
    // use a separate scrollview to ensure that the content does not push the buttons off-screen when scrolled
    ScrollView sv = new ScrollView(context);
    layout.addView(sv);
    // scrollView can only have one child
    LinearLayout previewLayout = new LinearLayout(context);
    previewLayout.setOrientation(LinearLayout.VERTICAL);
    sv.addView(previewLayout);
    FixedTextView label = new FixedTextView(context);
    label.setTextSize(20);
    label.setText(UiUtil.makeBold(context.getString(R.string.audio_recording_field_list)));
    label.setGravity(Gravity.CENTER_HORIZONTAL);
    previewLayout.addView(label);
    for (int i = 0; i < this.mNote.getInitialFieldCount(); i++) {
        IField field = mNote.getInitialField(i);
        FixedTextView textView = new FixedTextView(context);
        textView.setText(field.getText());
        textView.setTextSize(16);
        textView.setPadding(16, 0, 16, 24);
        previewLayout.addView(textView);
    }
}
Also used : ScrollView(android.widget.ScrollView) FixedTextView(com.ichi2.ui.FixedTextView) LinearLayout(android.widget.LinearLayout)

Example 3 with FixedTextView

use of com.ichi2.ui.FixedTextView in project Anki-Android by ankidroid.

the class CardInfo method addWithText.

private FixedTextView addWithText(TableRow row, Spannable value) {
    FixedTextView text = new FixedTextView(this);
    text.setText(value);
    text.setTextSize(12f);
    row.addView(text);
    return text;
}
Also used : FixedTextView(com.ichi2.ui.FixedTextView)

Aggregations

FixedTextView (com.ichi2.ui.FixedTextView)3 ViewTreeObserver (android.view.ViewTreeObserver)1 LinearLayout (android.widget.LinearLayout)1 ScrollView (android.widget.ScrollView)1