android.content.res.Resources#getText()源码实例Demo

下面列出了android.content.res.Resources#getText() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MaterialDesignSupport   文件: ResourceHelper.java
public static CharSequence getResText(int resourceId) {
    Context context = CoreMaterialApplication.getContext();
    if (context == null) {
        return null;
    }

    Resources resources = context.getResources();
    if (resources == null) {
        return null;
    }

    return resources.getText(resourceId);
}
 
源代码2 项目: PainlessMusicPlayer   文件: PlaybackModule.java
@Provides
SearchPlaybackInitializer provideSearchPlaybackInitializer(
        @NonNull final Resources resources,
        @NonNull final PlaybackInitializer playbackInitializer,
        @NonNull final PlaybackServiceControl playbackServiceControl,
        @NonNull final QueueProviderSearch queueProviderSearch) {
    return new SearchPlaybackInitializerImpl(
            resources.getText(R.string.No_media_found),
            resources.getString(R.string.No_media_found_for_s),
            playbackInitializer,
            playbackServiceControl,
            queueProviderSearch);
}
 
源代码3 项目: android_9.0.0_r45   文件: PreferenceActivity.java
/**
 * Return the currently set summary.  If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned.  Otherwise
 * {@link #summary} is returned.
 */
public CharSequence getSummary(Resources res) {
    if (summaryRes != 0) {
        return res.getText(summaryRes);
    }
    return summary;
}
 
源代码4 项目: PreferenceFragment   文件: PreferenceActivity.java
/**
 * Return the currently set summary. If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned. Otherwise {@link #summary} is
 * returned.
 */
public CharSequence getSummary(Resources res) {
    if (summaryRes != 0) {
        return res.getText(summaryRes);
    }
    return summary;
}
 
源代码5 项目: PreferenceFragment   文件: PreferenceActivity.java
/**
 * Return the currently set bread crumb title. If {@link #breadCrumbTitleRes} is set,
 * this resource is loaded from <var>res</var> and returned. Otherwise
 * {@link #breadCrumbTitle} is returned.
 */
public CharSequence getBreadCrumbTitle(Resources res) {
    if (breadCrumbTitleRes != 0) {
        return res.getText(breadCrumbTitleRes);
    }
    return breadCrumbTitle;
}
 
源代码6 项目: android-apps   文件: MenuBuilder.java
private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes,
        final Drawable icon, final View view) {
    final Resources r = getResources();

    if (view != null) {
        mHeaderView = view;

        // If using a custom view, then the title and icon aren't used
        mHeaderTitle = null;
        mHeaderIcon = null;
    } else {
        if (titleRes > 0) {
            mHeaderTitle = r.getText(titleRes);
        } else if (title != null) {
            mHeaderTitle = title;
        }

        if (iconRes > 0) {
            mHeaderIcon = r.getDrawable(iconRes);
        } else if (icon != null) {
            mHeaderIcon = icon;
        }

        // If using the title or icon, then a custom view isn't used
        mHeaderView = null;
    }

    // Notify of change
    onItemsChanged(false);
}
 
源代码7 项目: java-n-IDE-for-Android   文件: LatinKeyboard.java
/**
 * This looks at the ime options given by the current editor, to set the
 * appropriate label on the keyboard's enter key (if it has one).
 */
void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    int valnorm = KeyEvent.KEYCODE_ENTER;

    switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_go_key);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_next_key);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.codes = NORMAL_ENTER;
            mEnterKey.label = res.getText(R.string.label_send_key);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            mEnterKey.codes = TERMINAL_ENTER;
            break;
    }
}
 
源代码8 项目: AcDisplay   文件: DashboardCategory.java
/**
 * Return the currently set title. If {@link #titleRes} is set,
 * this resource is loaded from <var>res</var> and stored in {@link #title}.
 */
public CharSequence getTitle(Resources res) {
    if (titleRes != 0) {
        title = res.getText(titleRes);
        titleRes = 0;
    }

    return title;
}
 
源代码9 项目: AndroidKeyboard   文件: LatinKeyboard.java
/**
 * This looks at the ime options given by the current editor, to set the
 * appropriate label on the keyboard's enter key (if it has one).
 */
void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }
    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_go_key);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_next_key);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.ic_search_45dp);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_send_key);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.ic_check_circle_45dp);
            mEnterKey.label = null;
            break;
    }
}
 
源代码10 项目: 365browser   文件: DataReductionPreferences.java
/**
 * Returns summary string.
 */
public static String generateSummary(Resources resources) {
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
        String percent = DataReductionProxySettings.getInstance()
                .getContentLengthPercentSavings();
        return resources.getString(
                R.string.data_reduction_menu_item_summary, percent);
    } else {
        return (String) resources.getText(R.string.text_off);
    }
}
 
源代码11 项目: delion   文件: DataReductionPreferences.java
/**
 * Returns summary string.
 */
public static String generateSummary(Resources resources) {
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
        String percent = DataReductionProxySettings.getInstance()
                .getContentLengthPercentSavings();
        return resources.getString(
                R.string.data_reduction_menu_item_summary, percent);
    } else {
        return (String) resources.getText(R.string.text_off);
    }
}
 
源代码12 项目: AndroidChromium   文件: DataReductionPreferences.java
/**
 * Returns summary string.
 */
public static String generateSummary(Resources resources) {
    if (DataReductionProxySettings.getInstance().isDataReductionProxyEnabled()) {
        String percent = DataReductionProxySettings.getInstance()
                .getContentLengthPercentSavings();
        return resources.getString(
                R.string.data_reduction_menu_item_summary, percent);
    } else {
        return (String) resources.getText(R.string.text_off);
    }
}
 
源代码13 项目: kboard   文件: KBoard.java
public void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_go);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_next);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_send);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            break;
    }
}
 
源代码14 项目: Androzic   文件: Preferences.java
/**
 * Return the currently set bread crumb short title. If {@link #breadCrumbShortTitleRes} is set,
 * this resource is loaded from <var>res</var> and returned. Otherwise {@link #breadCrumbShortTitle} is returned.
 */
public CharSequence getBreadCrumbShortTitle(Resources res)
{
	if (breadCrumbShortTitleRes != 0)
	{
		return res.getText(breadCrumbShortTitleRes);
	}
	return breadCrumbShortTitle;
}
 
源代码15 项目: ticdesign   文件: PreferenceActivity.java
/**
 * Return the currently set summary.  If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned.  Otherwise
 * {@link #summary} is returned.
 */
public CharSequence getSummary(Resources res) {
    if (summaryRes != 0) {
        return res.getText(summaryRes);
    }
    return summary;
}
 
private void setHeaderInternal(final int titleRes, final CharSequence title, final int iconRes,
        final Drawable icon, final View view) {
    final Resources r = getResources();

    if (view != null) {
        mHeaderView = view;

        // If using a custom view, then the title and icon aren't used
        mHeaderTitle = null;
        mHeaderIcon = null;
    } else {
        if (titleRes > 0) {
            mHeaderTitle = r.getText(titleRes);
        } else if (title != null) {
            mHeaderTitle = title;
        }

        if (iconRes > 0) {
            mHeaderIcon = r.getDrawable(iconRes);
        } else if (icon != null) {
            mHeaderIcon = icon;
        }

        // If using the title or icon, then a custom view isn't used
        mHeaderView = null;
    }

    // Notify of change
    onItemsChanged(false);
}
 
源代码17 项目: kboard   文件: KBoard.java
public void setImeOptions(Resources res, int options) {
    if (mEnterKey == null) {
        return;
    }

    switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
        case EditorInfo.IME_ACTION_GO:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_go);
            break;
        case EditorInfo.IME_ACTION_NEXT:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_next);
            break;
        case EditorInfo.IME_ACTION_SEARCH:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_search);
            mEnterKey.label = null;
            break;
        case EditorInfo.IME_ACTION_SEND:
            mEnterKey.iconPreview = null;
            mEnterKey.icon = null;
            mEnterKey.label = res.getText(R.string.label_keyboard_key_send);
            break;
        default:
            mEnterKey.icon = res.getDrawable(R.drawable.sym_keyboard_return);
            mEnterKey.label = null;
            break;
    }
}
 
源代码18 项目: AppOpsXposed   文件: AppOpsState.java
public CharSequence getTimeText(Resources res, boolean showEmptyText) {
    if (isRunning()) {
        return res.getText(R.string.app_ops_running);
    }
    if (getTime() > 0) {
        return DateUtils.getRelativeTimeSpanString(getTime(),
                System.currentTimeMillis(),
                DateUtils.MINUTE_IN_MILLIS,
                DateUtils.FORMAT_ABBREV_RELATIVE);
    }
    return showEmptyText ? res.getText(R.string.app_ops_never_used) : "";
}
 
源代码19 项目: Popeens-DSub   文件: DSubWidgetProvider.java
/**
    * Update all active widget instances by pushing changes
    */
   private void performUpdate(Context context, DownloadService service, int[] appWidgetIds, boolean playing) {
       final Resources res = context.getResources();
       final RemoteViews views = new RemoteViews(context.getPackageName(), getLayout());

	if(playing) {
		views.setViewVisibility(R.id.widget_root, View.VISIBLE);
	} else {
		// Hide widget
		SharedPreferences prefs = Util.getPreferences(context);
		if(prefs.getBoolean(Constants.PREFERENCES_KEY_HIDE_WIDGET, false)) {
			views.setViewVisibility(R.id.widget_root, View.GONE);
		}
	}

// Get Entry from current playing DownloadFile
       MusicDirectory.Entry currentPlaying = null;
       if(service == null) {
       	// Deserialize from playling list to setup
           try {
               PlayerQueue state = FileUtil.deserialize(context, DownloadServiceLifecycleSupport.FILENAME_DOWNLOADS_SER, PlayerQueue.class);
               if (state != null && state.currentPlayingIndex != -1) {
                   currentPlaying = state.songs.get(state.currentPlayingIndex);
               }
           } catch(Exception e) {
               Log.e(TAG, "Failed to grab current playing", e);
           }
       } else {
		currentPlaying = service.getCurrentPlaying() == null ? null : service.getCurrentPlaying().getSong();
       }
       
       String title = currentPlaying == null ? null : currentPlaying.getTitle();
       CharSequence artist = currentPlaying == null ? null : currentPlaying.getArtist();
	CharSequence album = currentPlaying == null ? null : currentPlaying.getAlbum();
       CharSequence errorState = null;

       // Show error message?
       String status = Environment.getExternalStorageState();
       if (status.equals(Environment.MEDIA_SHARED) ||
           status.equals(Environment.MEDIA_UNMOUNTED)) {
           errorState = res.getText(R.string.widget_sdcard_busy);
       } else if (status.equals(Environment.MEDIA_REMOVED)) {
           errorState = res.getText(R.string.widget_sdcard_missing);
       } else if (currentPlaying == null) {
           errorState = res.getText(R.string.widget_initial_text);
       }

       setText(views, title, artist, album, errorState);

       // Set correct drawable for pause state
       if (playing) {
           views.setImageViewResource(R.id.control_play, R.drawable.media_pause_dark);
       } else {
           views.setImageViewResource(R.id.control_play, R.drawable.media_start_dark);
       }

       setImage(views, context, currentPlaying);

       // Link actions buttons to intents
       linkButtons(context, views, currentPlaying != null);

       pushUpdate(context, appWidgetIds, views);
   }
 
源代码20 项目: HeadsUp   文件: DashboardTile.java
/**
 * Return the currently set summary.  If {@link #summaryRes} is set,
 * this resource is loaded from <var>res</var> and returned.  Otherwise
 * {@link #summary} is returned.
 */
public CharSequence getSummary(Resources res) {
    return summaryRes != 0 ? res.getText(summaryRes) : summary;
}