类android.support.annotation.StyleRes源码实例Demo

下面列出了怎么用android.support.annotation.StyleRes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: DMusic   文件: AbstractAlertDialog.java
/**
 * Creates a dialog window that uses a custom dialog style.
 *
 * @param context    Context
 * @param themeResId The dialog's layout resource
 * @param isSetWin   Set the gravity of the window
 * @param gravity    The desired gravity constant
 * @param width      The dialog's width
 * @param heith      The dialog's height
 */
protected AbstractAlertDialog(@NonNull Context context, @StyleRes int themeResId, boolean isSetWin, int gravity, int width, int heith) {
    super(context, themeResId);
    this.mContext = context;
    this.mRootView = LayoutInflater.from(context).inflate(getLayoutRes(), null);
    setContentView(this.mRootView);
    setCanceledOnTouchOutside(true);
    setCancelable(true);
    if (isSetWin) {
        Window dialogWindow = getWindow();
        if (dialogWindow != null) {
            dialogWindow.setWindowAnimations(-1);
            dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
            dialogWindow.getDecorView().setPadding(0, 0, 0, 0);
            dialogWindow.setGravity(gravity);
            // Get the current layout param of the dialog
            WindowManager.LayoutParams p = dialogWindow.getAttributes();
            // Set dialog's width
            p.width = width;
            // Set dialog's height
            p.height = heith;
            dialogWindow.setAttributes(p);
        }
    }
    init(this.mRootView);
}
 
源代码2 项目: Common   文件: AbstractAlertDialog.java
/**
 * Creates a dialog window that uses a custom dialog style.
 *
 * @param context    Context
 * @param themeResId The dialog's layout resource
 * @param isSetWin   Set the gravity of the window
 * @param gravity    The desired gravity constant
 * @param width      The dialog's width
 * @param heith      The dialog's height
 */
protected AbstractAlertDialog(@NonNull Context context, @StyleRes int themeResId, boolean isSetWin, int gravity, int width, int heith) {
    super(context, themeResId);
    this.mContext = context;
    this.mRootView = LayoutInflater.from(context).inflate(getLayoutRes(), null);
    setContentView(this.mRootView);
    setCanceledOnTouchOutside(true);
    setCancelable(true);
    if (isSetWin) {
        Window dialogWindow = getWindow();
        if (dialogWindow != null) {
            dialogWindow.setWindowAnimations(-1);
            dialogWindow.setBackgroundDrawableResource(android.R.color.transparent);
            dialogWindow.getDecorView().setPadding(0, 0, 0, 0);
            dialogWindow.setGravity(gravity);
            // Get the current layout param of the dialog
            WindowManager.LayoutParams p = dialogWindow.getAttributes();
            // Set dialog's width
            p.width = width;
            // Set dialog's height
            p.height = heith;
            dialogWindow.setAttributes(p);
        }
    }
    init(this.mRootView);
}
 
/**
 * Construct an instance of {@link NavigationMapRoute}.
 *
 * @param navigation an instance of the {@link MapboxNavigation} object. Passing in null means
 *                   your route won't consider rerouting during a navigation session.
 * @param mapView    the MapView to apply the route to
 * @param mapboxMap  the MapboxMap to apply route with
 * @param styleRes   a style resource with custom route colors, scale, etc.
 * @param belowLayer optionally pass in a layer id to place the route line below
 */
public NavigationMapRoute(@Nullable MapboxNavigation navigation, @NonNull MapView mapView,
                          @NonNull MapboxMap mapboxMap, @StyleRes int styleRes,
                          @Nullable String belowLayer) {
  this.styleRes = styleRes;
  this.mapView = mapView;
  this.mapboxMap = mapboxMap;
  this.navigation = navigation;
  this.belowLayer = belowLayer;
  featureCollections = new ArrayList<>();
  directionsRoutes = new ArrayList<>();
  routeLineStrings = new HashMap<>();
  layerIds = new ArrayList<>();
  initialize();
  addListeners();
}
 
源代码4 项目: searchablespinner   文件: SearchableSpinner.java
public SearchableSpinner(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    mContext = context;
    getAttributeSet(attrs, defStyleAttr, defStyleRes);

    final LayoutInflater factory = LayoutInflater.from(context);
    factory.inflate(R.layout.view_searchable_spinner, this, true);

    mSpinnerListContainer = (LinearLayout) factory.inflate(R.layout.view_list, this, false);
    mSpinnerListView = (ListView) mSpinnerListContainer.findViewById(R.id.LstVw_SpinnerListView);
    if (mListItemDivider != null) {
        mSpinnerListView.setDivider(mListItemDivider);
        mSpinnerListView.setDividerHeight(mListDividerSize);
    }
    mEmptyTextView = (TextView) mSpinnerListContainer.findViewById(R.id.TxtVw_EmptyText);
    mSpinnerListView.setEmptyView(mEmptyTextView);
}
 
源代码5 项目: searchablespinner   文件: SearchableSpinner.java
private void getAttributeSet(@Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    if (attrs != null) {
        try {
            TypedArray attributes = mContext.getTheme().obtainStyledAttributes(attrs, R.styleable.SearchableSpinner, defStyleAttr, defStyleRes);
            mRevealViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_RevealViewBackgroundColor, Color.WHITE);
            mStartEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_StartSearchTintColor, Color.GRAY);
            mEditViewBackgroundColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewBackgroundColor, Color.WHITE);
            mEditViewTextColor = attributes.getColor(R.styleable.SearchableSpinner_SearchViewTextColor, Color.BLACK);
            mDoneEditTintColor = attributes.getColor(R.styleable.SearchableSpinner_DoneSearchTintColor, Color.GRAY);
            mBordersSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_BordersSize, 4);
            mExpandSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_SpinnerExpandHeight, 0);
            mShowBorders = attributes.getBoolean(R.styleable.SearchableSpinner_ShowBorders, false);
            mBoarderColor = attributes.getColor(R.styleable.SearchableSpinner_BoarderColor, Color.GRAY);
            mAnimDuration = attributes.getColor(R.styleable.SearchableSpinner_AnimDuration, DefaultAnimationDuration);
            mKeepLastSearch = attributes.getBoolean(R.styleable.SearchableSpinner_KeepLastSearch, false);
            mRevealEmptyText = attributes.getString(R.styleable.SearchableSpinner_RevealEmptyText);
            mSearchHintText = attributes.getString(R.styleable.SearchableSpinner_SearchHintText);
            mNoItemsFoundText = attributes.getString(R.styleable.SearchableSpinner_NoItemsFoundText);
            mListItemDivider = attributes.getDrawable(R.styleable.SearchableSpinner_ItemsDivider);
            mListDividerSize = attributes.getDimensionPixelSize(R.styleable.SearchableSpinner_DividerHeight, 0);
        } catch (UnsupportedOperationException e) {
            Log.e("SearchableSpinner", "getAttributeSet --> " + e.getLocalizedMessage());
        }
    }
}
 
源代码6 项目: scene   文件: ThemeDemo.java
public static TestTheme0Scene newInstance(@StyleRes int themeId) {
    TestTheme0Scene scene = new TestTheme0Scene();
    Bundle bundle = new Bundle();
    bundle.putInt("themeId", themeId);
    scene.setArguments(bundle);
    scene.setTheme(themeId);
    return scene;
}
 
源代码7 项目: scene   文件: ThemeDemo.java
public static TestTheme1Scene newInstance(@StyleRes int themeId) {
    TestTheme1Scene scene = new TestTheme1Scene();
    Bundle bundle = new Bundle();
    bundle.putInt("themeId", themeId);
    scene.setArguments(bundle);
    return scene;
}
 
源代码8 项目: scene   文件: SceneContextThemeWrapper.java
@Override
public void setTheme(@StyleRes int resid) {
    if (mThemeResource != resid) {
        mThemeResource = resid;
        if (mIsThemeFromActivity) {
            //reset
            mTheme = null;
            mResources = null;
        }
        initializeTheme();
    }
}
 
源代码9 项目: andela-crypto-app   文件: TransparentActivity.java
@StyleRes
protected int getThemeRes(int index) {
    try {
        return themes[index];
    } catch (Exception e) {
        Timber.e(e);
        return themes[0];
    }
}
 
@Override
public void setItemTextAppearance(@StyleRes int resId) {
    super.setItemTextAppearance(resId);
    if (resId != INVALID_ID) {
        TypedArray a = getContext().obtainStyledAttributes(resId, R.styleable.SkinTextAppearance);
        if (a.hasValue(R.styleable.SkinTextAppearance_android_textColor)) {
            mTextColorResId = a.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        }
        a.recycle();
        applyItemTextColorResource();
    }
}
 
源代码11 项目: RetroMusicPlayer   文件: PreferenceUtil.java
@StyleRes
public static int getThemeResFromPrefValue(String themePrefValue) {
    switch (themePrefValue) {
        case "dark":
            return R.style.Theme_RetroMusic;
        case "black":
            return R.style.Theme_RetroMusic_Black;
        case "light":
        default:
            return R.style.Theme_RetroMusic_Light;
    }
}
 
源代码12 项目: Luhn   文件: Luhn.java
public static void startLuhn(Context context, LuhnCallback luhnCallback, Bundle cardIOBundle, @StyleRes int style) {
    sLuhnCallback = luhnCallback;
    context.startActivity(new Intent(context, Luhn.class)
            .putExtra(STYLE_KEY, style)
            .putExtra(CARD_IO, cardIOBundle)
    );
}
 
protected ItemPickerViewAlertDialog(@NonNull final Context context,
                                    @StyleRes final int themeResId,
                                    @NonNull final ViewGroup parent,
                                    @NonNull final Listener listener) {
    super(context, themeResId);
    final View view = LayoutInflater.from(context).inflate(R.layout.alert_dialog_item_picker_view, parent, false);
    setView(view);
    this.listener = listener;
    this.adapter = new ItemRecyclerViewAdapter<>();
    this.recyclerView = (RecyclerView) view.findViewById(R.id.alert_dialog_item_picker_view_recycler);
    init();

}
 
源代码14 项目: Orin   文件: PreferenceUtil.java
@StyleRes
public static int getThemeResFromPrefValue(String themePrefValue) {
    switch (themePrefValue) {
        case "dark":
            return R.style.Theme_Phonograph;
        case "black":
            return R.style.Theme_Phonograph_Black;
        case "light":
        default:
            return R.style.Theme_Phonograph_Light;
    }
}
 
源代码15 项目: HoldingButton   文件: HoldingButtonLayout.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public HoldingButtonLayout(@NonNull Context context,
                           @Nullable AttributeSet attrs,
                           @AttrRes int defStyleAttr,
                           @StyleRes int defStyleRes) {

    super(context, attrs, defStyleAttr, defStyleRes);
    init(context, attrs, defStyleAttr, defStyleRes);
}
 
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ExpandableButtonView(@NonNull Context context, @Nullable AttributeSet attrs,
                            @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    init(context);
    initAttrs(attrs);
}
 
private void loadErrorTextColorResFromAttributes(@StyleRes int resId) {
    if (resId != INVALID_ID) {
        TypedArray errorTA = getContext().obtainStyledAttributes(resId, skin.support.R.styleable.SkinTextAppearance);
        if (errorTA.hasValue(skin.support.R.styleable.SkinTextAppearance_android_textColor)) {
            mErrorTextColorResId = errorTA.getResourceId(skin.support.R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        }
        errorTA.recycle();
    }
    applyErrorTextColorResource();
}
 
public static NumberPadTimePickerDialogFragment newInstance(OnTimeSetListener listener,
        @DialogMode int dialogMode, @StyleRes int themeResId, boolean customTheme) {
    NumberPadTimePickerDialogFragment f = new NumberPadTimePickerDialogFragment();
    Bundle args = new Bundle();
    args.putInt(KEY_THEME_RES_ID, themeResId);
    args.putInt(KEY_DIALOG_MODE, dialogMode);
    args.putBoolean(KEY_CUSTOM_THEME, customTheme);
    f.setArguments(args);
    f.listener = listener;
    return f;
}
 
源代码19 项目: NumberPadTimePicker   文件: CustomThemeModel.java
@StyleRes
public int getBaseAlertTheme() {
    switch (getBaseThemeValue(sharedPrefs)) {
        case 0:
        default:
            return R.style.Theme_AppCompat_Light_Dialog_Alert;
        case 1:
            return R.style.Theme_AppCompat_Dialog_Alert;
    }
}
 
源代码20 项目: NumberPadTimePicker   文件: CustomThemeModel.java
@StyleRes
public int getBaseBottomSheetTheme() {
    switch (getBaseThemeValue(sharedPrefs)) {
        case 0:
        default:
            return R.style.Theme_Design_Light_BottomSheetDialog;
        case 1:
            return R.style.Theme_Design_BottomSheetDialog;
    }
}
 
源代码21 项目: OpenHub   文件: ThemeHelper.java
@StyleRes
public static int getAboutTheme(String theme){
    switch (theme){
        case PrefUtils.LIGHT_TEAL:
            return R.style.ThemeLightTeal_AboutActivity;
        case PrefUtils.LIGHT_INDIGO:
            return R.style.ThemeLight_AboutActivity;
        case PrefUtils.DARK:
            return R.style.ThemeDark_AboutActivity;
        case PrefUtils.AMOLED_DARK:
            return R.style.ThemeAmoledDark_AboutActivity;
        default:
            return R.style.ThemeLightTeal_AboutActivity;
    }
}
 
源代码22 项目: andela-crypto-app   文件: ThemableActivity.java
@StyleRes
protected int getThemeRes(int index) {
    try {
        return themes[index];
    } catch (Exception e) {
        Timber.e(e);
        return themes[0];
    }
}
 
public NumberPadTimePickerDialog(@NonNull Context context, @StyleRes int themeResId,
        @Nullable OnTimeSetListener listener, boolean is24HourMode) {
    super(context, resolveDialogTheme(context, themeResId));

    final View root = getLayoutInflater().inflate(
            R.layout.nptp_alert_numberpad_time_picker_dialog, null);
    final NumberPadTimePicker timePicker = (NumberPadTimePicker)
            root.findViewById(R.id.nptp_time_picker);
    final NumberPadTimePickerAlertComponent timePickerComponent =
            (NumberPadTimePickerAlertComponent) timePicker.getComponent();
    final DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(
            this, timePicker.getPresenter());

    DialogViewInitializer.setupDialogView(this, presenter, getContext(),
            timePicker, timePickerComponent.getOkButton(), listener, is24HourMode);
    timePickerComponent.getCancelButton().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            presenter.onCancelClick();
        }
    });

    mThemer = new NumberPadTimePickerDialogThemer(timePickerComponent);
    mIs24HourMode = is24HourMode;

    // Must be requested before adding content, or get an AndroidRuntimeException!
    supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(root);
}
 
源代码24 项目: star-zone-android   文件: ProgressDialog.java
private ProgressDialog(@NonNull Activity activity, @StyleRes int theme) {
    super(activity, theme);
    setContentView(R.layout.dialog_progress);
    ButterKnife.bind(this);
}
 
源代码25 项目: star-zone-android   文件: ProgressDialogHelper.java
public ProgressDialogHelper(@NonNull Context context, @StyleRes int themeResId) {
    super(context, themeResId);
}
 
源代码26 项目: scene   文件: SceneNavigator.java
public SceneNavigator(@NonNull Context context, @StyleRes int themeResId) {
    this(context, themeResId, new ArrayList<SceneNavigationContainer>());
}
 
源代码27 项目: scene   文件: SceneNavigator.java
public SceneNavigator(@NonNull Context context, @StyleRes int themeResId, @Nullable SceneNavigationContainer container) {
    this(context, themeResId, toList(container));
}
 
源代码28 项目: SETransitionDemo   文件: DismissFrameLayout.java
@TargetApi(21)
public DismissFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    init();
}
 
源代码29 项目: scene   文件: BottomSheetDialogScene.java
public BottomSheetDialogScene(@StyleRes int theme) {
    this.mTheme = theme;
}
 
源代码30 项目: YCAudioPlayer   文件: BaseActivity.java
@StyleRes
protected int getDarkTheme() {
    return R.style.AppThemeDark;
}
 
 类方法
 同包方法