下面列出了android.app.TimePickerDialog.OnTimeSetListener#android.support.annotation.StyleRes 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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);
}
/**
* 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();
}
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);
}
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());
}
}
}
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;
}
public static TestTheme1Scene newInstance(@StyleRes int themeId) {
TestTheme1Scene scene = new TestTheme1Scene();
Bundle bundle = new Bundle();
bundle.putInt("themeId", themeId);
scene.setArguments(bundle);
return scene;
}
@Override
public void setTheme(@StyleRes int resid) {
if (mThemeResource != resid) {
mThemeResource = resid;
if (mIsThemeFromActivity) {
//reset
mTheme = null;
mResources = null;
}
initializeTheme();
}
}
@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();
}
}
@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;
}
}
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();
}
@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;
}
}
@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;
}
@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;
}
}
@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;
}
}
@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;
}
}
@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);
}
private ProgressDialog(@NonNull Activity activity, @StyleRes int theme) {
super(activity, theme);
setContentView(R.layout.dialog_progress);
ButterKnife.bind(this);
}
public ProgressDialogHelper(@NonNull Context context, @StyleRes int themeResId) {
super(context, themeResId);
}
public SceneNavigator(@NonNull Context context, @StyleRes int themeResId) {
this(context, themeResId, new ArrayList<SceneNavigationContainer>());
}
public SceneNavigator(@NonNull Context context, @StyleRes int themeResId, @Nullable SceneNavigationContainer container) {
this(context, themeResId, toList(container));
}
@TargetApi(21)
public DismissFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init();
}
public BottomSheetDialogScene(@StyleRes int theme) {
this.mTheme = theme;
}
@StyleRes
protected int getDarkTheme() {
return R.style.AppThemeDark;
}