Example usage for android.content.res Resources getString

List of usage examples for android.content.res Resources getString

Introduction

In this page you can find the example usage for android.content.res Resources getString.

Prototype

@NonNull
public String getString(@StringRes int id) throws NotFoundException 

Source Link

Document

Return the string value associated with a particular resource ID.

Usage

From source file:com.scigames.slidegame.Registration2RFIDActivity.java

/** Called with the activity is first created. */
@Override/*  w w w .ja v a2  s  .  co  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "super.OnCreate");
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    Intent i = getIntent();
    Log.d(TAG, "getIntent");
    visitIdIn = i.getStringExtra("visitId");
    studentIdIn = i.getStringExtra("studentId");

    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    //classIdIn = i.getStringExtra("mClass");
    //passwordIn = i.getStringExtra("mPass");
    Log.d(TAG, "...getStringExtra:");
    //Log.d(TAG,firstNameIn+lastNameIn);

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.registration2_rfid);
    Log.d(TAG, "...setContentView: registration2_rfid");

    // Find the text editor view inside the layout, because we
    // want to do various programmatic things with it.
    braceletId = (EditText) findViewById(R.id.bracelet_id);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    Log.d(TAG, "...braceletId EditText set");
    braceletId.setInputType(InputType.TYPE_NULL);
    Log.d(TAG, "...setInputType");
    braceletId.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            braceletId.setInputType(InputType.TYPE_CLASS_TEXT);
            braceletId.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });
    //firstName = (EditText) findViewById(R.id.first_name);
    //lastName = (EditText) findViewById(R.id.last_name);
    //password = (EditText) findViewById(R.id.password);
    Log.d(TAG, "...instantiateEditTexts");

    //        Log.d(TAG,"firstNameIn:");
    //        Log.d(TAG,firstNameIn);
    //        Log.d(TAG,"lastNameIn:");
    //        Log.d(TAG,lastNameIn);

    //set info to what we know already
    //lastName.setText(lastNameIn);
    // Log.d(TAG,"...lastName.setText");
    //firstName.setText(firstNameIn);
    // Log.d(TAG,"...firstName.setText");

    //display name in greeting sentence
    Resources res = getResources();
    TextView greets = (TextView) findViewById(R.id.greeting);
    Log.d(TAG, "...TextView greets find greeting");
    greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn));
    Log.d(TAG, greets.toString());
    Log.d(TAG, "...Greetings");

    // Hook up button presses to the appropriate event handler.
    ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);
    ((Button) findViewById(R.id.scan)).setOnClickListener(mScanButtonListener);
    Log.d(TAG, "...instantiateButtons");

    task.setOnResultsListener(this);
}

From source file:com.customdatepicker.time.CircleView.java

public void initialize(Context context, TimePickerController controller) {
    if (mIsInitialized) {
        Log.e(TAG, "CircleView may only be initialized once.");
        return;//from   w  w  w .  j av  a  2s  .  c o m
    }

    Resources res = context.getResources();

    int colorRes = controller.isThemeDark() ? R.color.mdtp_circle_background_dark_theme
            : R.color.mdtp_circle_color;
    mCircleColor = ContextCompat.getColor(context, colorRes);
    mDotColor = controller.getAccentColor();
    mPaint.setAntiAlias(true);

    mIs24HourMode = controller.is24HourMode();
    if (mIs24HourMode || controller.getVersion() != TimePickerDialog.Version.VERSION_1) {
        mCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    }

    mIsInitialized = true;
}

From source file:com.brewcrewfoo.performance.fragments.MemSettings.java

public void openDialog(final int idx, int currentProgress, String title, final int min, final int max,
        final Preference pref, final String path, final String key) {
    Resources res = getActivity().getResources();
    String cancel = res.getString(R.string.cancel);
    String ok = res.getString(R.string.ok);
    LayoutInflater factory = LayoutInflater.from(getActivity());
    final View alphaDialog = factory.inflate(R.layout.seekbar_dialog, null);

    final SeekBar seekbar = (SeekBar) alphaDialog.findViewById(R.id.seek_bar);

    seekbar.setMax(max);//from w  w w  . ja v a 2  s  .c  o  m
    seekbar.setProgress(currentProgress);

    settingText = (EditText) alphaDialog.findViewById(R.id.setting_text);
    settingText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                int val = Integer.parseInt(settingText.getText().toString());
                seekbar.setProgress(val);
                return true;
            }
            return false;
        }
    });
    settingText.setText(Integer.toString(currentProgress));
    settingText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            try {
                int val = Integer.parseInt(s.toString());
                if (val > max) {
                    s.replace(0, s.length(), Integer.toString(max));
                    val = max;
                }
                seekbar.setProgress(val);
            } catch (NumberFormatException ex) {
            }
        }
    });

    OnSeekBarChangeListener seekBarChangeListener = new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) {
            mSeekbarProgress = seekbar.getProgress();
            if (fromUser) {
                settingText.setText(Integer.toString(mSeekbarProgress));
            }
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekbar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekbar) {
        }
    };
    seekbar.setOnSeekBarChangeListener(seekBarChangeListener);

    new AlertDialog.Builder(getActivity()).setTitle(title).setView(alphaDialog)
            .setNegativeButton(cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // nothing
                }
            }).setPositiveButton(ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    int val = Integer.parseInt(settingText.getText().toString());
                    if (val < min) {
                        val = min;
                    }
                    seekbar.setProgress(val);
                    int newProgress = seekbar.getProgress();
                    values[idx] = Integer.toString(newProgress * 256);
                    pref.setSummary(newProgress + " MB " + "(" + values[idx] + ")");
                    new CMDProcessor().su
                            .runWaitFor("busybox echo " + implodeArray(values, ",") + " > " + path);
                    final SharedPreferences.Editor editor = mPreferences.edit();
                    editor.putString(key, implodeArray(values, ","));
                    editor.commit();
                }
            }).create().show();

}

From source file:com.chauffeurprive.kronos.time.RadialTextsView.java

public void initialize(Context context, String[] texts, String[] innerTexts, TimePickerController controller,
        SelectionValidator validator, boolean disappearsOut) {
    if (mIsInitialized) {
        Log.e(TAG, "This RadialTextsView may only be initialized once.");
        return;/*from   ww w. j a v  a2  s  . c  o m*/
    }
    Resources res = context.getResources();

    // Set up the paint.
    int textColorRes = controller.getTextColor();
    mPaint.setColor(ContextCompat.getColor(context, textColorRes));
    String typefaceFamily = res.getString(R.string.mdtp_radial_numbers_typeface);
    mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL);
    String typefaceFamilyRegular = res.getString(R.string.mdtp_sans_serif);
    mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    // Set up the selected paint
    int selectedTextColor = ContextCompat.getColor(context, controller.getSelectedTextColor());
    mSelectedPaint.setColor(selectedTextColor);
    mSelectedPaint.setAntiAlias(true);
    mSelectedPaint.setTextAlign(Align.CENTER);

    // Set up the inactive paint
    int inactiveColorRes = controller.getDisabledTextColor();
    mInactivePaint.setColor(ContextCompat.getColor(context, inactiveColorRes));
    mInactivePaint.setAntiAlias(true);
    mInactivePaint.setTextAlign(Align.CENTER);

    mTexts = texts;
    mInnerTexts = innerTexts;
    mIs24HourMode = controller.is24HourMode();
    mHasInnerCircle = (innerTexts != null);

    // Calculate the radius for the main circle.
    if (mIs24HourMode) {
        mCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    }

    // Initialize the widths and heights of the grid, and calculate the values for the numbers.
    mTextGridHeights = new float[7];
    mTextGridWidths = new float[7];
    if (mHasInnerCircle) {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_outer));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_outer));
        mInnerNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_inner));
        mInnerTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_inner));

        mInnerTextGridHeights = new float[7];
        mInnerTextGridWidths = new float[7];
    } else {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_normal));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_normal));
    }

    mAnimationRadiusMultiplier = 1;
    mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1));
    mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1));
    mInvalidateUpdateListener = new InvalidateUpdateListener();

    mValidator = validator;

    mTextGridValuesDirty = true;
    mIsInitialized = true;
}

From source file:com.example.android.aberdean.popularmoviesi.MovieDetails.java

/**
 * Assigns the appropriate values for the chosen movie.
 * @param savedInstanceState the previously saved state
 *///from  w  w  w.  jav  a  2  s. co  m
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.movie_details);

    mBackdrop = (ImageView) findViewById(R.id.iv_backdrop);
    mPosterThumb = (ImageView) findViewById(R.id.iv_poster_thumb);

    mSynopsis = (TextView) findViewById(R.id.tv_synopsis);
    mReleaseDate = (TextView) findViewById(R.id.tv_release_date);
    TextView mOriginalTitle = (TextView) findViewById(R.id.tv_title);
    mRating = (TextView) findViewById(R.id.tv_rating);

    Intent intent = getIntent();

    if (intent != null && intent.hasExtra("movieDetails")) {

        Resources res = getResources();

        ArrayList mChosenMovie = (ArrayList<?>) intent.getSerializableExtra("movieDetails");

        String posterUri = mChosenMovie.get(0).toString();
        String backdropUri = mChosenMovie.get(1).toString();
        setImage(posterUri, backdropUri);

        String synopsis = mChosenMovie.get(2).toString();
        mSynopsis.setText(synopsis);

        String releaseDate = mChosenMovie.get(3).toString();
        String release = String.format(res.getString(R.string.released), releaseDate);
        mReleaseDate.setText(release);

        String title = mChosenMovie.get(4).toString();
        mOriginalTitle.setText(title);

        String rating = mChosenMovie.get(5).toString();
        String rate = String.format(res.getString(R.string.rating), rating);
        mRating.setText(rate);
    }
}

From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java

public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener,
        View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) {
    Resources res = launcher.getResources();
    mLauncher = launcher;//from w ww  .  ja  v a 2 s  .  c  o  m
    mApps = apps;
    mEmptySearchMessage = res.getString(R.string.all_apps_loading_message);
    mGridSizer = new GridSpanSizer();
    mGridLayoutMgr = new AppsGridLayoutManager(launcher);
    mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
    mItemDecoration = new GridItemDecoration();
    mLayoutInflater = LayoutInflater.from(launcher);
    mTouchListener = touchListener;
    mIconClickListener = iconClickListener;
    mIconLongClickListener = iconLongClickListener;
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset);

    mSectionTextPaint = new Paint();
    mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size));
    mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color));
    mSectionTextPaint.setAntiAlias(true);

    mPredictedAppsDividerPaint = new Paint();
    mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics()));
    mPredictedAppsDividerPaint.setColor(0x1E000000);
    mPredictedAppsDividerPaint.setAntiAlias(true);
    mPredictionBarDividerOffset = (-res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_bottom_padding)
            + res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding)) / 2;

    // Resolve the market app handling additional searches
    PackageManager pm = launcher.getPackageManager();
    ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""),
            PackageManager.MATCH_DEFAULT_ONLY);
    if (marketInfo != null) {
        mMarketAppName = marketInfo.loadLabel(pm).toString();
    }
}

From source file:com.androidinspain.deskclock.data.TimerNotificationBuilder.java

Notification buildMissed(Context context, NotificationModel nm, List<Timer> missedTimers) {
    final Timer timer = missedTimers.get(0);
    final int count = missedTimers.size();

    // Compute some values required below.
    final long base = getChronometerBase(timer);
    final String pname = context.getPackageName();
    final Resources res = context.getResources();

    final Action action;

    final CharSequence stateText;
    if (count == 1) {
        // Single timer is missed.
        if (TextUtils.isEmpty(timer.getLabel())) {
            stateText = res.getString(com.androidinspain.deskclock.R.string.missed_timer_notification_label);
        } else {// ww w . j ava  2s .com
            stateText = res.getString(
                    com.androidinspain.deskclock.R.string.missed_named_timer_notification_label,
                    timer.getLabel());
        }

        // Reset button
        final Intent reset = new Intent(context, TimerService.class).setAction(TimerService.ACTION_RESET_TIMER)
                .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId());

        @DrawableRes
        final int icon1 = com.androidinspain.deskclock.R.drawable.ic_reset_24dp;
        final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.timer_reset);
        final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset);
        action = new Action.Builder(icon1, title1, intent1).build();
    } else {
        // Multiple missed timers.
        stateText = res.getString(com.androidinspain.deskclock.R.string.timer_multi_missed, count);

        final Intent reset = TimerService.createResetMissedTimersIntent(context);

        @DrawableRes
        final int icon1 = com.androidinspain.deskclock.R.drawable.ic_reset_24dp;
        final CharSequence title1 = res.getText(com.androidinspain.deskclock.R.string.timer_reset_all);
        final PendingIntent intent1 = Utils.pendingServiceIntent(context, reset);
        action = new Action.Builder(icon1, title1, intent1).build();
    }

    // Intent to load the app and show the timer when the notification is tapped.
    final Intent showApp = new Intent(context, TimerService.class).setAction(TimerService.ACTION_SHOW_TIMER)
            .putExtra(TimerService.EXTRA_TIMER_ID, timer.getId())
            .putExtra(Events.EXTRA_EVENT_LABEL, com.androidinspain.deskclock.R.string.label_notification);

    final PendingIntent pendingShowApp = PendingIntent.getService(context, REQUEST_CODE_MISSING, showApp,
            PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_UPDATE_CURRENT);

    final Builder notification = new NotificationCompat.Builder(context).setLocalOnly(true).setShowWhen(false)
            .setAutoCancel(false).setContentIntent(pendingShowApp).setPriority(Notification.PRIORITY_HIGH)
            .setCategory(NotificationCompat.CATEGORY_ALARM)
            .setSmallIcon(com.androidinspain.deskclock.R.drawable.stat_notify_timer)
            .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
            .setSortKey(nm.getTimerNotificationMissedSortKey())
            .setStyle(new NotificationCompat.DecoratedCustomViewStyle()).addAction(action)
            .setColor(ContextCompat.getColor(context, com.androidinspain.deskclock.R.color.default_background));

    if (Utils.isNOrLater()) {
        notification.setCustomContentView(buildChronometer(pname, base, true, stateText))
                .setGroup(nm.getTimerNotificationGroupKey());
    } else {
        final CharSequence contentText = AlarmUtils.getFormattedTime(context,
                timer.getWallClockExpirationTime());
        notification.setContentText(contentText).setContentTitle(stateText);
    }

    return notification.build();
}

From source file:com.google.android.apps.forscience.whistlepunk.project.ProjectTabsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Resources res = getResources();
    View view = inflater.inflate(R.layout.fragment_project_list, container, false);
    mEmptyView = (TextView) view.findViewById(R.id.empty);
    mEmptyView.setText(res.getString(R.string.empty_project_library));
    mEmptyView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null,
            res.getDrawable(R.drawable.empty_project));
    mRecyclerView = (RecyclerView) view.findViewById(R.id.projects_list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator() {

        private void setAlpha(RecyclerView.ViewHolder item) {
            // The default item animator messes with the alpha, so we need to reset the alpha.
            ProjectAdapter.CardViewHolder holder = (ProjectAdapter.CardViewHolder) item;
            holder.itemView.setAlpha(holder.itemView.getResources()
                    .getFraction(holder.archivedIndicator.getVisibility() == View.VISIBLE
                            ? R.fraction.metadata_card_archived_alpha
                            : R.fraction.metadata_card_alpha, 1, 1));
        }//from  w  w w  . j a va  2  s. c  om

        @Override
        public void onAddFinished(RecyclerView.ViewHolder item) {
            setAlpha(item);
        }

        @Override
        public void onChangeFinished(RecyclerView.ViewHolder item, boolean oldItem) {
            setAlpha(item);
        }
    });
    mAdapter = new ProjectAdapter();
    mRecyclerView.setAdapter(mAdapter);
    if (savedInstanceState != null) {
        mIncludeArchived = savedInstanceState.getBoolean(EXTRA_INCLUDE_ARCHIVED, false);
    }
    FloatingActionButton createProjectBtn = (FloatingActionButton) view
            .findViewById(R.id.create_project_button);
    createProjectBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getDataController().createProject(new LoggingConsumer<Project>(TAG, "Create project") {
                @Override
                public void success(Project project) {
                    UpdateProjectActivity.launch(getActivity(), project.getProjectId(), true /* new project */);
                }
            });
        }
    });

    return view;
}

From source file:com.android.launcher3.allapps.AllAppsGridAdapter.java

public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener,
        View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) {
    Resources res = launcher.getResources();
    mLauncher = launcher;/*  ww w . jav  a2  s  . c  o  m*/
    mApps = apps;
    mEmptySearchMessage = res.getString(R.string.all_apps_loading_message);
    mGridSizer = new GridSpanSizer();
    mGridLayoutMgr = new AppsGridLayoutManager(launcher);
    mGridLayoutMgr.setSpanSizeLookup(mGridSizer);
    mItemDecoration = new GridItemDecoration();
    mLayoutInflater = LayoutInflater.from(launcher);
    mTouchListener = touchListener;
    mIconClickListener = iconClickListener;
    mIconLongClickListener = iconLongClickListener;
    mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin);
    mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset);
    mIsRtl = Utilities.isRtl(res);

    mSectionTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size));
    mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color));

    mPredictedAppsDividerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics()));
    mPredictedAppsDividerPaint.setColor(0x1E000000);
    mPredictionBarDividerOffset = (-res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_bottom_padding)
            + res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding)) / 2;
}

From source file:com.android.datetimepicker.time.RadialTextsView.java

public void initialize(Context context, String[] texts, String[] innerTexts, TimePickerController controller,
        SelectionValidator validator, boolean disappearsOut) {
    if (mIsInitialized) {
        Log.e(TAG, "This RadialTextsView may only be initialized once.");
        return;/* w  w w . j  a v  a 2 s . c  om*/
    }
    Resources res = context.getResources();

    // Set up the paint.
    int textColorRes = controller.isThemeDark() ? R.color.mdtp_white : R.color.mdtp_numbers_text_color;
    mPaint.setColor(ContextCompat.getColor(context, textColorRes));
    String typefaceFamily = res.getString(R.string.mdtp_radial_numbers_typeface);
    mTypefaceLight = Typeface.create(typefaceFamily, Typeface.NORMAL);
    String typefaceFamilyRegular = res.getString(R.string.mdtp_sans_serif);
    mTypefaceRegular = Typeface.create(typefaceFamilyRegular, Typeface.NORMAL);
    mPaint.setAntiAlias(true);
    mPaint.setTextAlign(Align.CENTER);

    // Set up the selected paint
    int selectedTextColor = ContextCompat.getColor(context, R.color.mdtp_white);
    mSelectedPaint.setColor(selectedTextColor);
    mSelectedPaint.setAntiAlias(true);
    mSelectedPaint.setTextAlign(Align.CENTER);

    // Set up the inactive paint
    int inactiveColorRes = controller.isThemeDark() ? R.color.mdtp_date_picker_text_disabled_dark_theme
            : R.color.mdtp_date_picker_text_disabled;
    mInactivePaint.setColor(ContextCompat.getColor(context, inactiveColorRes));
    mInactivePaint.setAntiAlias(true);
    mInactivePaint.setTextAlign(Align.CENTER);

    mTexts = texts;
    mInnerTexts = innerTexts;
    mIs24HourMode = controller.is24HourMode();
    mHasInnerCircle = (innerTexts != null);

    // Calculate the radius for the main circle.
    if (mIs24HourMode) {
        mCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode));
    } else {
        mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_circle_radius_multiplier));
        mAmPmCircleRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier));
    }

    // Initialize the widths and heights of the grid, and calculate the values for the numbers.
    mTextGridHeights = new float[7];
    mTextGridWidths = new float[7];
    if (mHasInnerCircle) {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_outer));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_outer));
        mInnerNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_inner));
        mInnerTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_inner));

        mInnerTextGridHeights = new float[7];
        mInnerTextGridWidths = new float[7];
    } else {
        mNumbersRadiusMultiplier = Float
                .parseFloat(res.getString(R.string.mdtp_numbers_radius_multiplier_normal));
        mTextSizeMultiplier = Float.parseFloat(res.getString(R.string.mdtp_text_size_multiplier_normal));
    }

    mAnimationRadiusMultiplier = 1;
    mTransitionMidRadiusMultiplier = 1f + (0.05f * (disappearsOut ? -1 : 1));
    mTransitionEndRadiusMultiplier = 1f + (0.3f * (disappearsOut ? 1 : -1));
    mInvalidateUpdateListener = new InvalidateUpdateListener();

    mValidator = validator;

    mTextGridValuesDirty = true;
    mIsInitialized = true;
}