下面列出了android.support.v7.app.AppCompatDelegate#setCompatVectorFromResourcesEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_word_set);
ButterKnife.bind(this);
((FriendSpellApplication) getApplication()).component().inject(this);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
try {
init();
} catch (IOException e) {
Timber.e(Log.getStackTraceString(e));
}
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
// Don't initialize analytics with debug build
if (!BuildConfig.DEBUG) {
Fabric.with(this, new Crashlytics());
}
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Utils.DARK_THEME = Themes.isDarkTheme(this);
Themes.Theme theme = Themes.getTheme(this, Utils.DARK_THEME);
if (Utils.DARK_THEME) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
setTheme(theme.getStyle());
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) {
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(statusBarColor());
}
}
@Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
configureShortcuts(getApplicationContext());
setApplicationShortcuts(getApplicationContext());
try {
long currentId = getCurrentId(getApplicationContext());
if (currentId > 0) {
SQRLStorage.getInstance(getApplicationContext()).read(IdentityDBHelper.getInstance(getApplicationContext()).getIdentityData(currentId));
}
EntropyHarvester.getInstance();
} catch (Exception e) {
Log.e(TAG, "Failed to get initiate EntropyHarvester or SQRLStorage.");
}
}
public void onCreate() {
super.onCreate();
// initialize Realm database
Realm.init(this);
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
// create new instance of the application component (DI)
mApplicationComponent = DaggerApplicationComponent
.builder()
.applicationModule(new ApplicationModule(this))
.build();
// initialize vault
Vault.initializeVault(this);
generateEncryptionKey();
// initialize fingerprint
Reprint.initialize(this);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
@Override
public void onCreate() {
super.onCreate();
// SkinCircleImageViewManager.init(this);
// SkinMaterialManager.init(this);
// SkinConstraintManager.init(this);
// SkinCardViewManager.init(this);
// SkinFlycoTabLayoutManager.init(this);
// SkinCompatManager.init(this).loadSkin();
// SkinCompatManager.init(this)
// 框架换肤日志打印
Slog.DEBUG = true;
SkinCompatManager.withoutActivity(this)
.addStrategy(new CustomSDCardLoader()) // 自定义加载策略,指定SDCard路径
.addStrategy(new ZipSDCardLoader()) // 自定义加载策略,获取zip包中的资源
.addInflater(new SkinMaterialViewInflater()) // material design
.addInflater(new SkinConstraintViewInflater()) // ConstraintLayout
.addInflater(new SkinCardViewInflater()) // CardView v7
.addInflater(new SkinCircleImageViewInflater()) // hdodenhof/CircleImageView
.addInflater(new SkinFlycoTabLayoutInflater()) // H07000223/FlycoTabLayout
.setSkinStatusBarColorEnable(true) // 关闭状态栏换肤
// .setSkinWindowBackgroundEnable(false) // 关闭windowBackground换肤
// .setSkinAllActivityEnable(false) // true: 默认所有的Activity都换肤; false: 只有实现SkinCompatSupportable接口的Activity换肤
.loadSkin();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
public ContactAdapter(Context context) {
this.context = context;
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
// Get colors from theme
TypedValue typedValueHighlight = new TypedValue();
context.getTheme().resolveAttribute(R.attr.backgroundElement, typedValueHighlight, true);
colorHighlight = typedValueHighlight.data;
TypedValue typedValuePrimary = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorPrimary, typedValuePrimary, true);
colorPrimary = typedValuePrimary.data;
// Init color primary inverse
TypedValue typedValueSecondary = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorPrimaryInverse, typedValueSecondary, true);
colorPrimaryInverse = typedValueSecondary.data;
// Init circle background
circleBackground = ContextCompat.getDrawable(context, R.drawable.background_circle);
circleBackground.setColorFilter(colorPrimaryInverse, PorterDuff.Mode.SRC_ATOP);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
((FriendSpellApplication) getApplication()).component().inject(this);
ButterKnife.bind(this);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
googleApiClientToken = googleApiClientBridge.init(this, this, this);
setTitle(null);
try {
init();
} catch (IOException e) {
Timber.e(Log.getStackTraceString(e));
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
if (getArguments() != null) {
product = (Product) getArguments().getSerializable(ARG_PARAM1);
isEdit = getArguments().getBoolean(ARG_PARAM2);
}
}
@Override
public void onCreate() {
super.onCreate();
systemOut = new InterceptorOutputStream(System.out, out);
systemErr = new InterceptorOutputStream(System.err, err);
System.setOut(systemOut);
System.setErr(systemErr);
//for log cat
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
@Override
public void onCreate() {
super.onCreate();
systemOut = new InterceptorOutputStream(System.out, out);
systemErr = new InterceptorOutputStream(System.err, err);
System.setOut(systemOut);
System.setErr(systemErr);
//for log cat
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
IdePreferenceManager.setDefaultValues(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
initItemsData();
gridLayoutManager = new GridLayoutManager(this, SPAN_COUNT_ONE);
itemAdapter = new ItemAdapter(items, gridLayoutManager);
recyclerView = (RecyclerView) findViewById(R.id.rv);
recyclerView.setAdapter(itemAdapter);
recyclerView.setLayoutManager(gridLayoutManager);
}
@Override
public boolean onCreate() {
//Fix for loading some vector images in api < 21
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
NetworkModule.initialize(getContext());
Session.initialize(getContext(), NetworkModule.INSTANCE);
ConnectionHelper.getInstance().initialize(getContext());
return false;
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
if (getSupportFragmentManager().findFragmentById(R.id.container) == null)
{
_app_display = new AppDisplayFragment();
getSupportFragmentManager().beginTransaction()
.add(R.id.container, _app_display, APP_FRAGMENT_TAG)
.commit();
// Load update sources
UpdateSource.initialize_update_sources(this);
}
else {
_app_display = (AppDisplayFragment) getSupportFragmentManager().findFragmentByTag(APP_FRAGMENT_TAG);
}
// Schedule automatic version checks.
WakefulIntentService.scheduleAlarms(new PollReceiver(), this);
// ApkTrack cannot recieve Intents about its own upgrades. A manual check has to
// be performed at startup to update its version number if needed. The same goes
// update APKs which may have been downloaded.
new Thread(new Runnable() {
@Override
public void run() {
InstalledApp.detect_new_version(getApplicationContext(), getPackageName());
}
}).start();
_handle_intent(getIntent());
}
private void enableVectorDrawable() {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_spell);
ButterKnife.bind(this);
((FriendSpellApplication) getApplication()).component().inject(this);
// Allows older platform to use vector drawables within DrawableContainer resources.
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
// home button goes up by a single level instead of going back to the top level or front page.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
circleTransform = new CircleTransform();
seenMultiSourceTip = pref.getBoolean(Constants.KEY_SEEN_MULTI_SOURCE, false);
refreshUI();
googleApiClientToken = googleApiClientBridge.init(this, this, this);
}
private NoInternetDialog(@NonNull Context context, int bgGradientStart, int bgGradientCenter, int bgGradientEnd,
int bgGradientOrientation, int bgGradientType, float dialogRadius,
@Nullable Typeface titleTypeface, @Nullable Typeface messageTypeface,
int buttonColor, int buttonTextColor, int buttonIconsColor, int wifiLoaderColor,
boolean cancelable) {
super(context);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
isHalloween = NoInternetUtils.getCurrentDate().equals("10-31");
this.bgGradientStart = bgGradientStart == 0
? (isHalloween
? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradStartH)
: ContextCompat.getColor(getContext(), R.color.colorNoInternetGradStart))
: bgGradientStart;
this.bgGradientCenter = bgGradientCenter == 0
? (isHalloween
? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH)
: ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenter))
: bgGradientCenter;
this.bgGradientEnd = bgGradientEnd == 0
? (isHalloween
? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradEndH)
: ContextCompat.getColor(getContext(), R.color.colorNoInternetGradEnd))
: bgGradientEnd;
this.bgGradientOrientation = bgGradientOrientation < 10 || bgGradientOrientation > 17 ? ORIENTATION_TOP_BOTTOM : bgGradientOrientation;
this.bgGradientType = bgGradientType <= 0 || bgGradientType > 2 ? GRADIENT_LINEAR : bgGradientType;
this.dialogRadius = dialogRadius == 0 ? RADIUS : dialogRadius;
if (dialogRadius == NO_RADIUS) {
this.dialogRadius = 0f;
}
this.titleTypeface = titleTypeface;
this.messageTypeface = messageTypeface;
this.buttonColor = buttonColor == 0
? (isHalloween
? ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH)
: ContextCompat.getColor(getContext(), R.color.colorAccent))
: buttonColor;
this.buttonTextColor = buttonTextColor == 0
? ContextCompat.getColor(getContext(), R.color.colorWhite)
: buttonTextColor;
this.buttonIconsColor = buttonIconsColor == 0
? ContextCompat.getColor(getContext(), R.color.colorWhite)
: buttonIconsColor;
this.wifiLoaderColor = wifiLoaderColor == 0
? ContextCompat.getColor(getContext(), R.color.colorWhite)
: wifiLoaderColor;
this.cancelable = cancelable;
initReceivers(context);
}
@Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
@Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Need to add when vector drawables support library is used.
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
handler = new Handler();
Display display = getWindowManager().getDefaultDisplay();
displayMetrics = getResources().getDisplayMetrics();
display.getRealMetrics(displayMetrics);
density = displayMetrics.density;
LocalBroadcastManager.getInstance(this).registerReceiver(closeBroadcastReceiver,
new IntentFilter(FolioReader.ACTION_CLOSE_FOLIOREADER));
// Fix for screen get turned off while reading
// TODO -> Make this configurable
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setConfig(savedInstanceState);
initDistractionFreeMode(savedInstanceState);
setContentView(R.layout.folio_activity);
this.savedInstanceState = savedInstanceState;
if (savedInstanceState != null) {
searchAdapterDataBundle = savedInstanceState.getBundle(SearchAdapter.DATA_BUNDLE);
searchQuery = savedInstanceState.getCharSequence(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY);
}
mBookId = getIntent().getStringExtra(FolioReader.INTENT_BOOK_ID);
mEpubSourceType = (EpubSourceType)
getIntent().getExtras().getSerializable(FolioActivity.INTENT_EPUB_SOURCE_TYPE);
if (mEpubSourceType.equals(EpubSourceType.RAW)) {
mEpubRawId = getIntent().getExtras().getInt(FolioActivity.INTENT_EPUB_SOURCE_PATH);
} else {
mEpubFilePath = getIntent().getExtras()
.getString(FolioActivity.INTENT_EPUB_SOURCE_PATH);
}
initActionBar();
initMediaController();
if (ContextCompat.checkSelfPermission(FolioActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(FolioActivity.this, Constants.getWriteExternalStoragePerms(), Constants.WRITE_EXTERNAL_STORAGE_REQUEST);
} else {
setupBook();
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place_detail);
//Enable support for vector drawables on Pre-lollipop devices
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
if (getIntent().getExtras() != null) {
place_id = getIntent().getStringExtra("place_id");
place_name = getIntent().getStringExtra("place_name");
image_URL = getIntent().getStringExtra("image_URL");
Log.d(TAG, "Image url " + image_URL);
//Toast.makeText(this, place_id, Toast.LENGTH_SHORT).show();
}
// Initialize Firebase components
mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseDatabase = FirebaseDatabase.getInstance();
//Views and click listeners
coordinatorLayout = (CoordinatorLayout) findViewById(R.id.activity_place_detail);
fabFav = (FloatingActionButton) findViewById(R.id.fab_favorite);
rbRatingBar = (RatingBar) findViewById(R.id.rating);
tvAddress = (TextView) findViewById(R.id.address);
llUrlIcon = (LinearLayout) findViewById(R.id.icon_link);
llCall = (LinearLayout) findViewById(R.id.icon_call);
llDirections = (LinearLayout) findViewById(R.id.icon_directions);
llReviews = (LinearLayout) findViewById(R.id.layout_reviews);
fabFav.setOnClickListener(this);
llUrlIcon.setOnClickListener(this);
llCall.setOnClickListener(this);
llDirections.setOnClickListener(this);
//Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar_layout);
collapsingToolbarLayout.setTitle(place_name);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
mBanner = (ImageView) findViewById(R.id.banner);
if (image_URL != null && !image_URL.isEmpty()) {
Picasso.with(this).load(image_URL).fit().into(mBanner);
}
//Ui
final String DOMAIN = Constants.BASE_URL_PLACE_DETAILS;
final String APPKEY_PARAM = Constants.API_KEY_PARAM;
final String PLACE_ID_PARAM = Constants.PLACE_ID_PARAM;
try {
StringBuilder sb = new StringBuilder(DOMAIN)
.append(PLACE_ID_PARAM + "=" + place_id)
.append("&" + APPKEY_PARAM + "=" + Constants.API_VALUE);
Log.d(TAG, "Place URL built " + sb.toString());
fetchPlaceDetails(sb.toString());
} catch (Exception e) {
Log.e(TAG, "Error building url");
}
//Firebase Auth listener
mAuthStateListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
onSignedInInitialize(user);
} else {
// User is signed out
onSignedOutCleanup();
//showFirebaseLogin();
}
}
};
}