android.support.annotation.XmlRes Java Examples

The following examples show how to use android.support.annotation.XmlRes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: ReminderDatePicker   Author: SimplicityApks   File: PickerSpinner.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 */
protected ArrayList<TwinTextItem> getItemsFromXml(@XmlRes int xmlResource)
        throws XmlPullParserException, IOException {
    final Resources res = getResources();
    XmlResourceParser parser = res.getXml(xmlResource);
    ArrayList<TwinTextItem> items = new ArrayList<>();

    int eventType;
    while((eventType = parser.next()) != XmlPullParser.END_DOCUMENT) {
        if(eventType == XmlPullParser.START_TAG) {
            // call our subclass to parse the correct item
            TwinTextItem item = parseItemFromXmlTag(parser);
            if(item != null)
                items.add(item);
        }
    }

    return items;
}
 
Example #2
Source Project: BottomBar   Author: roughike   File: BottomBar.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Set the item for the BottomBar from XML Resource with a default configuration
 * for each tab.
 */
public void setItems(@XmlRes int xmlRes, BottomBarTab.Config defaultTabConfig) {
    if (xmlRes == 0) {
        throw new RuntimeException("No items specified for the BottomBar!");
    }

    if (defaultTabConfig == null) {
        defaultTabConfig = getTabConfig();
    }

    TabParser parser = new TabParser(getContext(), defaultTabConfig, xmlRes);
    updateItems(parser.parseTabs());
}
 
Example #3
Source Project: ticdesign   Author: mobvoi   File: PreferenceFragment.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Inflates the given XML resource and adds the preference hierarchy to the current
 * preference hierarchy.
 *
 * @param preferencesResId The XML resource ID to inflate.
 */
public void addPreferencesFromResource(@XmlRes int preferencesResId) {
    requirePreferenceManager();

    setPreferenceScreen(mPreferenceManager.inflateFromResource(getActivity(),
            preferencesResId, getPreferenceScreen()));
}
 
Example #4
Source Project: ticdesign   Author: mobvoi   File: PreferenceFragmentCompat.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Inflates the given XML resource and adds the preference hierarchy to the current
 * preference hierarchy.
 *
 * @param preferencesResId The XML resource ID to inflate.
 */
public void addPreferencesFromResource(@XmlRes int preferencesResId) {
    requirePreferenceManager();

    setPreferenceScreen(mPreferenceManager.inflateFromResource(getActivity(),
            preferencesResId, getPreferenceScreen()));
}
 
Example #5
Source Project: WearPreferenceActivity   Author: denley   File: XmlPreferenceParser.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
WearPreferenceScreen parse(@NonNull final Context context, @XmlRes final int prefsResId) {
    try {
        final XmlResourceParser parser = context.getResources().getXml(prefsResId);
        return parseScreen(context, parser);
    } catch (XmlPullParserException | IOException e) {
        throw new RuntimeException("Error parsing preferences file", e);
    }
}
 
Example #6
Source Project: 365browser   Author: mogoweb   File: PreferenceUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * A helper that is used to load preferences from XML resources without causing a
 * StrictModeViolation. See http://crbug.com/692125.
 *
 * @param preferenceFragment A PreferenceFragment.
 * @param preferencesResId   The id of the XML resource to add to the PreferenceFragment.
 */
public static void addPreferencesFromResource(
        PreferenceFragment preferenceFragment, @XmlRes int preferencesResId) {
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        preferenceFragment.addPreferencesFromResource(preferencesResId);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
 
Example #7
Source Project: PowerFileExplorer   Author: PowerExplorer   File: ResourcesUtil.java    License: GNU General Public License v3.0 4 votes vote down vote up
public static XmlResourceParser getXml(@XmlRes int xmlRes) {
    return Base.getResources().getXml(xmlRes);
}
 
Example #8
Source Project: memetastic   Author: gsantner   File: GsPreferenceFragmentCompat.java    License: GNU General Public License v3.0 4 votes vote down vote up
@XmlRes
public abstract int getPreferenceResourceForInflation();
 
Example #9
Source Project: BottomBar   Author: roughike   File: BottomBar.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Set the items for the BottomBar from XML Resource.
 */
public void setItems(@XmlRes int xmlRes) {
    setItems(xmlRes, null);
}
 
Example #10
Source Project: BottomBar   Author: roughike   File: TabParser.java    License: Apache License 2.0 4 votes vote down vote up
TabParser(@NonNull Context context, @NonNull BottomBarTab.Config defaultTabConfig, @XmlRes int tabsXmlResId) {
    this.context = context;
    this.defaultTabConfig = defaultTabConfig;
    this.parser = context.getResources().getXml(tabsXmlResId);
}
 
Example #11
Source Project: openlauncher   Author: OpenLauncherTeam   File: GsPreferenceFragmentCompat.java    License: Apache License 2.0 4 votes vote down vote up
@XmlRes
public abstract int getPreferenceResourceForInflation();
 
Example #12
Source Project: Stringlate   Author: LonamiWebs   File: GsPreferenceFragmentCompat.java    License: MIT License 4 votes vote down vote up
@XmlRes
public abstract int getPreferenceResourceForInflation();
 
Example #13
Source Project: SwipeSelector   Author: roughike   File: SwipeItemParser.java    License: Apache License 2.0 4 votes vote down vote up
SwipeItemParser(Context context, @XmlRes int swipeItemsRes) {
    this.context = context;

    parser = context.getResources().getXml(swipeItemsRes);
    swipeItems = new ArrayList<>();
}
 
Example #14
Source Project: island   Author: oasisfeng   File: SettingsActivity.java    License: Apache License 2.0 4 votes vote down vote up
protected SubPreferenceFragment(final @XmlRes int preference_xml, final int... keys_to_bind_summary) {
	mPreferenceXml = preference_xml;
	mKeysToBindSummary = keys_to_bind_summary;
}
 
Example #15
Source Project: AcDisplay   Author: AChep   File: SettingsActivity.java    License: GNU General Public License v2.0 4 votes vote down vote up
@XmlRes
protected int getDashboardResource() {
    return 0;
}
 
Example #16
Source Project: AcDisplay   Author: AChep   File: Settings2.java    License: GNU General Public License v2.0 4 votes vote down vote up
@XmlRes
@Override
public int getDashboardResource() {
    return R.xml.settings_dashboard;
}
 
Example #17
Source Project: kimai-android   Author: gsantner   File: GsPreferenceFragmentCompat.java    License: MIT License 4 votes vote down vote up
@XmlRes
public abstract int getPreferenceResourceForInflation();
 
Example #18
Source Project: HeadsUp   Author: AChep   File: SettingsActivity.java    License: GNU General Public License v2.0 4 votes vote down vote up
@XmlRes
protected int getDashboardResource() {
    return 0;
}
 
Example #19
Source Project: Android-VMLib   Author: Shouheng88   File: BasePreferenceFragment.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Get preferences resources id.
 *
 * @return preferences resources id
 */
@XmlRes
protected abstract int getPreferencesResId();
 
Example #20
Source Project: WearPreferenceActivity   Author: denley   File: WearPreferenceActivity.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Inflates the preferences from the given resource and displays them on this page.
 * @param prefsResId    The resource ID of the preferences xml file.
 */
protected void addPreferencesFromResource(@XmlRes int prefsResId) {
    addPreferencesFromResource(prefsResId, new XmlPreferenceParser());
}
 
Example #21
Source Project: WearPreferenceActivity   Author: denley   File: WearPreferenceActivity.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Inflates the preferences from the given resource and displays them on this page.
 * @param prefsResId    The resource ID of the preferences xml file.
 * @param parser        A parser used to parse custom preference types
 */
protected void addPreferencesFromResource(@XmlRes int prefsResId, @NonNull XmlPreferenceParser parser) {
    final WearPreferenceScreen prefsRoot = parser.parse(this, prefsResId);
    addPreferencesFromPreferenceScreen(prefsRoot);
}