Search in sources :

Example 21 with StringRes

use of android.support.annotation.StringRes in project edx-app-android by edx.

the class ErrorNotification method showError.

/**
 * Show the error notification with the message appropriate for the provided error.
 *
 * @param context         The Context, to be used for checking connectivity status.
 * @param error           The error that occurred while attempting to retrieve from or deliver to the
 *                        remote server. This may be an {@link IOException} if the request failed due to a
 *                        network failure, an {HttpResponseStatusException} if the failure was due to
 *                        receiving an error code, or any {@link Throwable} implementation if one was
 *                        thrown unexpectedly while creating the request or processing the response.
 * @param actionTextResId The resource ID of the action button text.
 * @param actionListener  The callback to be invoked when the action button is clicked.
 */
public void showError(@NonNull final Context context, @NonNull final Throwable error, @StringRes int actionTextResId, @Nullable View.OnClickListener actionListener) {
    @StringRes final int errorResId = ErrorUtils.getErrorMessageRes(context, error, this);
    final Icon icon = ErrorUtils.getErrorIcon(error);
    if (errorResId == R.string.app_version_unsupported) {
        actionTextResId = R.string.label_update;
        actionListener = AppStoreUtils.OPEN_APP_IN_APP_STORE_CLICK_LISTENER;
    }
    showError(errorResId, icon, actionTextResId, actionListener);
}
Also used : StringRes(android.support.annotation.StringRes) Icon(com.joanzapata.iconify.Icon)

Example 22 with StringRes

use of android.support.annotation.StringRes in project edx-app-android by edx.

the class BulkDownloadFragment method setSwitchAccessibility.

private void setSwitchAccessibility(@StringRes int accessibilitySuffixStringRes) {
    @StringRes final int prefixStringRes = R.string.bulk_download_switch;
    final Resources resources = binding.swDownload.getResources();
    binding.swDownload.setContentDescription(resources.getString(prefixStringRes) + " " + binding.tvTitle.getText() + ". " + binding.tvSubtitle.getText() + ". " + resources.getString(accessibilitySuffixStringRes));
}
Also used : StringRes(android.support.annotation.StringRes) Resources(android.content.res.Resources) SuppressLint(android.annotation.SuppressLint)

Aggregations

StringRes (android.support.annotation.StringRes)22 SuppressLint (android.annotation.SuppressLint)7 View (android.view.View)6 Intent (android.content.Intent)5 ApiHelpers (com.gh4a.utils.ApiHelpers)4 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 Snackbar (android.support.design.widget.Snackbar)3 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Drawable (android.graphics.drawable.Drawable)2 Uri (android.net.Uri)2 DrawableRes (android.support.annotation.DrawableRes)2 NonNull (android.support.annotation.NonNull)2 FragmentManager (android.support.v4.app.FragmentManager)2 ActionBar (android.support.v7.app.ActionBar)2 TextView (android.widget.TextView)2 R (com.gh4a.R)2 File (java.io.File)2