當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextThemeWrapper類代碼示例

本文整理匯總了Java中android.support.v7.view.ContextThemeWrapper的典型用法代碼示例。如果您正苦於以下問題:Java ContextThemeWrapper類的具體用法?Java ContextThemeWrapper怎麽用?Java ContextThemeWrapper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContextThemeWrapper類屬於android.support.v7.view包,在下文中一共展示了ContextThemeWrapper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: get

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
public static TintManager get(Context context) {
    if (context == null) return null;

    if (context instanceof ContextThemeWrapper) {
        context = ((ContextThemeWrapper) context).getBaseContext();
    }
    if (context instanceof android.view.ContextThemeWrapper) {
        context = ((android.view.ContextThemeWrapper) context).getBaseContext();
    }
    TintManager tm = INSTANCE_CACHE.get(context);
    if (tm == null) {
        tm = new TintManager(context);
        INSTANCE_CACHE.put(context, tm);
        printLog("[getBaseApplication TintManager] create new TintManager.");
    }
    return tm;
}
 
開發者ID:Pingsh,項目名稱:Mix,代碼行數:18,代碼來源:TintManager.java

示例2: onCreateView

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
    LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
    View view = themeAwareInflater.inflate(layoutRes(), container, false);
    unbinder = ButterKnife.bind(this, view);
    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override public void onGlobalLayout() {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            View parent = getDialog().findViewById(R.id.design_bottom_sheet);
            if (parent != null) {
                bottomSheetBehavior = BottomSheetBehavior.from(parent);
                if (bottomSheetBehavior != null) {
                    bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
                    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                }
            }
        }
    });
    return view;
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:21,代碼來源:BaseBottomSheetDialog.java

示例3: onPrepareOptionsMenu

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    mToolbar.getMenu()
            .findItem(R.id.theme)
            .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    int style = new ColorPreferences(FeedViewSingle.this).getThemeSubreddit(
                            feed);
                    final Context contextThemeWrapper =
                            new ContextThemeWrapper(FeedViewSingle.this, style);
                    LayoutInflater localInflater =
                            getLayoutInflater().cloneInContext(contextThemeWrapper);
                    final View dialoglayout = localInflater.inflate(R.layout.colorsub, null);
                    ArrayList<String> arrayList = new ArrayList<>();
                    arrayList.add(feed);
                    Palette.showSubThemeEditor(arrayList, FeedViewSingle.this,
                            dialoglayout);
                    return false;
                }
            });
    return true;
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:26,代碼來源:FeedViewSingle.java

示例4: onPrepareOptionsMenu

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    this.menu = menu;
    menu.findItem(R.id.theme)
            .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    int style = new ColorPreferences(MainActivity.this).getThemeSubreddit(
                            selectedFeed.getTitle());
                    final Context contextThemeWrapper =
                            new ContextThemeWrapper(MainActivity.this, style);
                    LayoutInflater localInflater =
                            getLayoutInflater().cloneInContext(contextThemeWrapper);
                    final View dialoglayout =
                            localInflater.inflate(R.layout.colorsub, null);
                    ArrayList<String> arrayList = new ArrayList<>();
                    arrayList.add(selectedFeed.getTitle());
                    Palette.showSubThemeEditor(arrayList, MainActivity.this,
                            dialoglayout);
                    return false;
                }
            });
    return true;
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:27,代碼來源:MainActivity.java

示例5: setStyle

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
void setStyle(Context context) {
    TypedValue outValue = new TypedValue();
    Theme widgetTheme = context.getResources().newTheme();
    widgetTheme.setTo(context.getTheme());
    widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme, outValue, true);
    if (outValue.resourceId != 0) {
        widgetTheme.applyStyle(outValue.resourceId, true);
    }
    widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true);
    if (outValue.resourceId != 0) {
        widgetTheme.applyStyle(outValue.resourceId, true);
    } else {
        widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true);
    }
    Context context2 = new ContextThemeWrapper(context, 0);
    context2.getTheme().setTo(widgetTheme);
    this.listPresenterContext = context2;
    TypedArray a = context2.obtainStyledAttributes(R.styleable.AppCompatTheme);
    this.background = a.getResourceId(R.styleable.AppCompatTheme_panelBackground, 0);
    this.windowAnimations = a.getResourceId(R.styleable.AppCompatTheme_android_windowAnimationStyle, 0);
    a.recycle();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:23,代碼來源:AppCompatDelegateImplV7.java

示例6: initializePanelMenu

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
private boolean initializePanelMenu(PanelFeatureState st) {
    Context context = this.mContext;
    if ((st.featureId == 0 || st.featureId == 108) && this.mDecorContentParent != null) {
        TypedValue outValue = new TypedValue();
        Theme baseTheme = context.getTheme();
        baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
        Theme widgetTheme = null;
        if (outValue.resourceId != 0) {
            widgetTheme = context.getResources().newTheme();
            widgetTheme.setTo(baseTheme);
            widgetTheme.applyStyle(outValue.resourceId, true);
            widgetTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        } else {
            baseTheme.resolveAttribute(R.attr.actionBarWidgetTheme, outValue, true);
        }
        if (outValue.resourceId != 0) {
            if (widgetTheme == null) {
                widgetTheme = context.getResources().newTheme();
                widgetTheme.setTo(baseTheme);
            }
            widgetTheme.applyStyle(outValue.resourceId, true);
        }
        if (widgetTheme != null) {
            Context context2 = new ContextThemeWrapper(context, 0);
            context2.getTheme().setTo(widgetTheme);
            context = context2;
        }
    }
    MenuBuilder menu = new MenuBuilder(context);
    menu.setCallback(this);
    st.setMenu(menu);
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:34,代碼來源:AppCompatDelegateImplV7.java

示例7: themifyContext

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
private static Context themifyContext(Context context, AttributeSet attrs, boolean useAndroidTheme, boolean useAppTheme) {
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0);
    int themeId = 0;
    if (useAndroidTheme) {
        themeId = a.getResourceId(R.styleable.View_android_theme, 0);
    }
    if (useAppTheme && themeId == 0) {
        themeId = a.getResourceId(R.styleable.View_theme, 0);
        if (themeId != 0) {
            Log.i(LOG_TAG, "app:theme is now deprecated. Please move to using android:theme instead.");
        }
    }
    a.recycle();
    if (themeId == 0) {
        return context;
    }
    if ((context instanceof ContextThemeWrapper) && ((ContextThemeWrapper) context).getThemeResId() == themeId) {
        return context;
    }
    return new ContextThemeWrapper(context, themeId);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:AppCompatViewInflater.java

示例8: showDialogMessage

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
/**
 * Common method to show message in alert box.
 *
 * @param title the title
 * @param body  the body
 */
public void showDialogMessage(String title, String body,Context context) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.myDialog));
    builder.setTitle(title).setMessage(body).setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                mUserDialog.dismiss();
            } catch (Exception e) {
                Log.e(AppUtility.TAG, Log.getStackTraceString(e));
            }
        }
    });
    mUserDialog = builder.create();
    mUserDialog.show();
}
 
開發者ID:Welloculus,項目名稱:MobileAppForPatient,代碼行數:22,代碼來源:BaseActivity.java

示例9: showDialogMessage

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
private void showDialogMessage(String title, String body, final boolean exit) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.myDialog));
    builder.setTitle(title).setMessage(body).setNeutralButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                muserDialog.dismiss();
                if (exit) {
                    exit(mUsernameInput);
                }
            } catch (Exception e) {
                Log.e(AppUtility.TAG, Log.getStackTraceString(e));
                if (exit) {
                    exit(mUsernameInput);
                }
            }
        }
    });
    muserDialog = builder.create();
    muserDialog.show();
}
 
開發者ID:Welloculus,項目名稱:MobileAppForPatient,代碼行數:22,代碼來源:RegisterUser.java

示例10: get

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
public static com.bilibili.magicasakura.utils.TintManager get(Context context) {
    if (context == null) return null;

    if (context instanceof ContextThemeWrapper) {
        context = ((ContextThemeWrapper) context).getBaseContext();
    }
    if (context instanceof android.view.ContextThemeWrapper) {
        context = ((android.view.ContextThemeWrapper) context).getBaseContext();
    }
    com.bilibili.magicasakura.utils.TintManager tm = INSTANCE_CACHE.get(context);
    if (tm == null) {
        tm = new com.bilibili.magicasakura.utils.TintManager(context);
        INSTANCE_CACHE.put(context, tm);
        printLog("[get TintManager] create new TintManager.");
    }
    return tm;
}
 
開發者ID:Bilibili,項目名稱:MagicaSakura,代碼行數:18,代碼來源:TintManager.java

示例11: onCreate

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //apply activity's theme if dark theme is enabled
    themeWrapper = new ContextThemeWrapper(getBaseContext(), this.getTheme());

    Preferences.applyTheme(themeWrapper, getBaseContext());

    setContentView(R.layout.preference_activity);

    //provide back navigation
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    if (getFragmentManager().findFragmentById(R.id.content_frame) == null) {

        SettingsFragment settingsFragment = new SettingsFragment();
        getFragmentManager().beginTransaction().replace(R.id.content_frame, settingsFragment).commit();
    }

}
 
開發者ID:enricocid,項目名稱:Color-picker-library,代碼行數:24,代碼來源:PreferenceActivity.java

示例12: inflateDebugging

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
@SuppressLint("InflateParams")
private void inflateDebugging() {
    mDebuggingText = (TextView) LayoutInflater.from(new ContextThemeWrapper(mService, R.style.Theme_Velociraptor))
            .inflate(R.layout.floating_stats, null, false);

    WindowManager.LayoutParams debuggingParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            getWindowType(),
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE,
            PixelFormat.TRANSLUCENT);

    debuggingParams.gravity = Gravity.BOTTOM;
    try {
        mWindowManager.addView(mDebuggingText, debuggingParams);
    } catch (Exception e) {
        mService.showToast("Velociraptor error: " + e.getMessage());
    }
}
 
開發者ID:plusCubed,項目名稱:velociraptor,代碼行數:20,代碼來源:FloatingView.java

示例13: onCreateView

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
@SuppressLint("RestrictedApi")
public View onCreateView(String name, Context context, AttributeSet attrs) {
    final Resources.Theme theme = context.getTheme();
    switch (name) {
        case "Button":
            return new PandroidCompatButton(new ContextThemeWrapper(context, theme), attrs);
        case "EditText":
            return new PandroidCompatEditText(new ContextThemeWrapper(context, theme), attrs);
        case "RadioButton":
            return new PandroidCompatEditText(new ContextThemeWrapper(context, theme), attrs);
        case "Switch":
            return new PandroidCompatSwitch(new ContextThemeWrapper(context, theme), attrs);
        case "TextView":
            return new PandroidCompatTextView(new ContextThemeWrapper(context, theme), attrs);
        case "ToggleButton":
            return new ToggleButton(new ContextThemeWrapper(context, theme), attrs);
        default:
            return null;
    }
}
 
開發者ID:MobileTribe,項目名稱:pandroid,代碼行數:22,代碼來源:PandroidCompatViewFactory.java

示例14: show_ok_dialog

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
public static void show_ok_dialog(final Activity activity, String title, String message, final Runnable runnable) {
    try {
        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme));
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                if (runnable != null) {
                    runOnUiThreadDelayed(runnable, 10);
                }
            }
        });

        builder.create().show();
    } catch (Exception e) {
        Log.wtf(TAG, "show_dialog exception: " + e);
        static_toast_long(message);
    }
}
 
開發者ID:NightscoutFoundation,項目名稱:xDrip,代碼行數:21,代碼來源:JoH.java

示例15: onPreferenceTreeClick

import android.support.v7.view.ContextThemeWrapper; //導入依賴的package包/類
@Override
public boolean onPreferenceTreeClick(Preference preference) {
    if (preference.getKey().equals("delete_all")) {
        File myDownloads = Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_DOWNLOADS);
        // Add them to a list first before we sort them.
        deleteApks(myDownloads);
        Toast.makeText(getActivity(), R.string.downloaded_files_deleted, Toast.LENGTH_SHORT).show();
    } else if (preference.getKey().equals("build_variant")) {
        new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.dialog_theme))
                .setTitle(R.string.title_app_variants)
                .setMessage(R.string.build_variant_explanation)
                .show();
    }
    return super.onPreferenceTreeClick(preference);
}
 
開發者ID:ITVlab,項目名稱:TvAppRepo,代碼行數:17,代碼來源:SettingsFragment.java


注:本文中的android.support.v7.view.ContextThemeWrapper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。