本文整理汇总了Java中org.polaric.colorful.Colorful类的典型用法代码示例。如果您正苦于以下问题:Java Colorful类的具体用法?Java Colorful怎么用?Java Colorful使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Colorful类属于org.polaric.colorful包,在下文中一共展示了Colorful类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
cluttr=this;
Colorful.defaults().translucent(true);
Colorful.init(this);
ExtSdHelper.init();
prefs = PreferenceManager.getDefaultSharedPreferences(this);
newRelease = !(BuildConfig.VERSION_CODE == prefs.getInt("current_version",0));
Realm.init(this);
RealmConfiguration config = new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.directory(getCacheDir())
.build();
Realm.setDefaultConfiguration(config);
}
示例2: onCreate
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web);
ButterKnife.bind(this);
initializeToolbar();
mWebView = new WebView(this);
LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
mWebView.setLayoutParams(lp);
mContainer.addView(mWebView, 0);
if (Colorful.getThemeDelegate().isNight()) {
mContainer.setAlpha(0.7f);
}
if (getSupportActionBar() != null)
getSupportActionBar().setTitle(getIntent().getStringExtra("title"));
initWebView(getIntent().getStringExtra("url"));
}
示例3: onResume
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
mSwitch.setChecked(Colorful.getThemeDelegate().isNight());
mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
mDrawerLayout.addDrawerListener(new MyDrawerListener());
mDrawerLayout.closeDrawer(GravityCompat.START);
if (PrefUtil.isAutoDayNightMode()) {
Toast.makeText(MainActivity.this, getString(R.string.hint_auto_day_night_disabled),
Toast.LENGTH_LONG).show();
PrefUtil.setAutoDayNightMode(false);
}
}
});
}
示例4: onOptionsItemSelected
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_search) {
navigateWithRippleCompat(
this,
new Intent(this, SearchActivity.class),
item.getActionView(),
Colorful.getThemeDelegate().getPrimaryColor().getColorRes()
);
return true;
} else if (item.getItemId() == R.id.action_box_office) {
navigateWithRippleCompat(
this,
new Intent(this, BoxOfficeActivity.class),
item.getActionView(),
Colorful.getThemeDelegate().getPrimaryColor().getColorRes()
);
return true;
}
return super.onOptionsItemSelected(item);
}
示例5: switchDayNightModeSmoothly
import org.polaric.colorful.Colorful; //导入依赖的package包/类
private void switchDayNightModeSmoothly(final boolean isDark, boolean delay) {
if (delay) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Colorful.config(MainActivity.this).night(isDark).apply();
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
mAutoSwitchedHint = "已自动切换为" +
(isDark ? getString(R.string.night_mode) : getString(R.string.day_mode));
recreate();
}
}, 1000);
} else {
Colorful.config(MainActivity.this).night(isDark).apply();
getWindow().setWindowAnimations(R.style.WindowAnimationFadeInOut);
recreate();
}
}
示例6: onCreate
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
transparentStatusBar();
setContentView(R.layout.activity_theme);
if (savedInstanceState == null) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if (Colorful.getThemeDelegate().isNight()) {
ft.add(R.id.container, NightModeFragment.newInstance(), NightModeFragment.TAG);
} else {
ft.add(R.id.container, DayModeFragment.newInstance(), DayModeFragment.TAG);
}
ft.commit();
}
}
示例7: goToDetail
import org.polaric.colorful.Colorful; //导入依赖的package包/类
private void goToDetail(MovieModel movieModel, View view) {
if (movieModel.getWebUrl() == null || movieModel.getWebUrl().isEmpty()) {
showToast("无效地址");
} else {
Intent intent = new Intent(this, WebActivity.class);
intent.putExtra("url", movieModel.getWebUrl());
intent.putExtra("title", movieModel.getName() == null ? "" : movieModel.getName());
navigateWithRippleCompat(
this,
intent,
view,
Colorful.getThemeDelegate().getAccentColor().getColorRes()
);
}
}
示例8: openInChrome
import org.polaric.colorful.Colorful; //导入依赖的package包/类
private void openInChrome(String url) {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.setSecondaryToolbarColor(getResources().getColor(Colorful.getThemeDelegate().getPrimaryColor().getColorRes()));
builder.setToolbarColor(getResources().getColor(Colorful.getThemeDelegate().getPrimaryColor().getColorRes()));
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
}
示例9: onPreferenceChange
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
public boolean onPreferenceChange(Preference preference, Object o) {
switch (preference.getKey()) {
case "dark_theme": {
Colorful.config(getContext())
.dark(((boolean) o))
.apply();
getActivity().recreate();
break;
}
case "animations": {
Media.setUseAnimations((boolean) o);
break;
}
case "staggered": {
Media.setStaggered((boolean) o);
}
case "primary" : {
getActivity().recreate();
break;
}
case "accent" : {
getActivity().recreate();
break;
}
}
return true;
}
示例10: onBind
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
protected void onBind(final LicenseVH holder, int position) {
OpenModel openModel = mData.get(position);
holder.sourceText.setText(openModel.getName());
holder.licenseText.setText(openModel.getLicense());
holder.licenseText.setNight(Colorful.getThemeDelegate().isNight());
}
示例11: onCreate
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_box_office);
ButterKnife.bind(this);
initializeToolbar();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mAdapter.getData() != null && !mAdapter.getData().isEmpty())
mRecyclerView.smoothScrollToPosition(0);
}
});
mSwipeRefreshLayout.setColorSchemeColors(
ContextCompat.getColor(this, Colorful.getThemeDelegate().getAccentColor().getColorRes()),
ContextCompat.getColor(this, Colorful.getThemeDelegate().getPrimaryColor().getColorRes())
);
mSwipeRefreshLayout.setProgressViewEndTarget(false, (int) TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, 80, Resources.getSystem().getDisplayMetrics()));
mSwipeRefreshLayout.setRefreshing(true);
mSwipeRefreshLayout.setOnRefreshListener(this);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new BoxOfficeListAdapter();
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setItemAnimator(null);
mPresenter = new BoxOfficeActivityPresenterImpl();
mPresenter.register(this);
mPresenter.loadData();
}
示例12: checkAutoDayNightMode
import org.polaric.colorful.Colorful; //导入依赖的package包/类
/**
* 检测是否自动日夜模式,如果是自动将根据时间判断是否切换
*
* @return 是否立即加载数据
*/
private boolean checkAutoDayNightMode() {
boolean firstTime = PrefUtil.checkFirstTime();
if (firstTime)
PrefUtil.setNotFirstTime();
boolean auto = PrefUtil.isAutoDayNightMode();
if (firstTime || !auto)
return true;
int[] dayTime = PrefUtil.getDayNightModeStartTime(true);
int[] nightTime = PrefUtil.getDayNightModeStartTime(false);
Calendar cal = Calendar.getInstance();
int h = cal.get(Calendar.HOUR_OF_DAY);
int m = cal.get(Calendar.MINUTE);
if (Colorful.getThemeDelegate().isNight()) {
if ((dayTime[0] < h && h < nightTime[0]) || (dayTime[0] == h && dayTime[1] <= m)) {
switchDayNightModeSmoothly(false, true);
return false;
} else {
return true;
}
} else {
if ((nightTime[0] < h) || (nightTime[0] == h && nightTime[1] <= m)) {
switchDayNightModeSmoothly(true, true);
return false;
} else {
return true;
}
}
}
示例13: onCreate
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Colorful.defaults()
.primaryColor(Colorful.ThemeColor.RED)
.accentColor(Colorful.ThemeColor.BLUE)
.translucent(false)
.dark(true);
Colorful.init(this);
}
示例14: onCreate
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view);
ButterKnife.bind(this);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
if (getIntent().getAction()!=null && getIntent().getAction().equals(Intent.ACTION_VIEW)) {
String p = getIntent().getDataString();
path = Util.ContentResolverHelper.getPath(this, Uri.parse(p));
Log.d(Util.LOG_TAG, "Starting on VIEW intent for " + getIntent().getDataString());
adapter = new MediaViewAdapter(this, path, this);
pager.setAdapter(adapter);
setupMetadata();
} else {
Realm realm = Realm.getDefaultInstance();
album = realm.where(Album.class).equalTo("path",getIntent().getExtras().getString(Util.ALBUM_PASS_KEY)).findFirst();
media = getIntent().getExtras().getString(Util.MEDIA_PASS_KEY);
results = getResults();
int i = results.indexOf(album.getMedia().where().equalTo("path",media).findFirst());
adapter = new MediaViewAdapter(this, results, this);
pager.setAdapter(adapter);
pager.setCurrentItem(i);
viewToolbar.inflateMenu(R.menu.media_edit_toolbar);
if (!Colorful.getThemeDelegate().isDark()) {
Util.ViewUtils.colorizeToolbar(viewToolbar, Color.BLACK);
}
pager.addOnPageChangeListener(this);
setupMetadata();
}
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(this);
toolbar.setNavigationIcon(R.drawable.md_nav_back);
toolbar.inflateMenu(R.menu.media_item_toolbar);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
return false;
}
});
toolbar.setNavigationOnClickListener(this);
viewToolbar.setTitle(R.string.info);
if (Colorful.getThemeDelegate().isDark()) {
viewToolbar.setNavigationIcon(R.drawable.ic_close_white_48px);
} else {
viewToolbar.setNavigationIcon(R.drawable.ic_close_black_48px);
}
viewToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
close();
}
});
viewToolbar.setOnMenuItemClickListener(this);
startTimeOut();
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
toolbar.setTitleTextColor(Color.WHITE);
toolbar.setTitle(adapter.getPageTitle(pager.getCurrentItem()));
}
示例15: getTheme
import org.polaric.colorful.Colorful; //导入依赖的package包/类
@Override
int getTheme() {
return Colorful.getThemeDelegate().getStyleResPrimary();
}