Java Code Examples for com.danimahardhika.android.helpers.core.ColorHelper#isValidColor()
The following examples show how to use
com.danimahardhika.android.helpers.core.ColorHelper#isValidColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AboutAdapter.java From wallpaperboard with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == TYPE_HEADER) { HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder; String imageUri = mContext.getString(R.string.about_image); if (ColorHelper.isValidColor(imageUri)) { headerViewHolder.image.setBackgroundColor(Color.parseColor(imageUri)); } else if (!URLUtil.isValidUrl(imageUri)) { imageUri = "drawable://" + DrawableHelper.getResourceId(mContext, imageUri); ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions()); } else { ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions()); } String profileUri = mContext.getResources().getString(R.string.about_profile_image); if (!URLUtil.isValidUrl(profileUri)) { profileUri = "drawable://" + DrawableHelper.getResourceId(mContext, profileUri); } ImageLoader.getInstance().displayImage(profileUri, headerViewHolder.profile, ImageConfig.getDefaultImageOptions()); } }
Example 2
Source File: AboutAdapter.java From candybar with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == TYPE_HEADER) { HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder; String imageUri = mContext.getString(R.string.about_image); if (ColorHelper.isValidColor(imageUri)) { headerViewHolder.image.setBackgroundColor(Color.parseColor(imageUri)); } else if (!URLUtil.isValidUrl(imageUri)) { imageUri = "drawable://" + DrawableHelper.getResourceId(mContext, imageUri); ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions(true)); } else { ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions(true)); } String profileUri = mContext.getResources().getString(R.string.about_profile_image); if (!URLUtil.isValidUrl(profileUri)) { profileUri = "drawable://" + DrawableHelper.getResourceId(mContext, profileUri); } ImageLoader.getInstance().displayImage(profileUri, headerViewHolder.profile, ImageConfig.getDefaultImageOptions(true)); } }
Example 3
Source File: AboutAdapter.java From candybar-library with Apache License 2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == TYPE_HEADER) { HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder; String imageUri = mContext.getString(R.string.about_image); if (ColorHelper.isValidColor(imageUri)) { headerViewHolder.image.setBackgroundColor(Color.parseColor(imageUri)); } else if (!URLUtil.isValidUrl(imageUri)) { imageUri = "drawable://" + DrawableHelper.getResourceId(mContext, imageUri); ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions(true)); } else { ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions(true)); } String profileUri = mContext.getResources().getString(R.string.about_profile_image); if (!URLUtil.isValidUrl(profileUri)) { profileUri = "drawable://" + DrawableHelper.getResourceId(mContext, profileUri); } ImageLoader.getInstance().displayImage(profileUri, headerViewHolder.profile, ImageConfig.getDefaultImageOptions(true)); } }
Example 4
Source File: CandyBarMainActivity.java From candybar with Apache License 2.0 | 4 votes |
private void initNavigationViewHeader() { if (CandyBarApplication.getConfiguration().getNavigationViewHeader() == CandyBarApplication.NavigationViewHeader.NONE) { mNavigationView.removeHeaderView(mNavigationView.getHeaderView(0)); return; } String imageUrl = getResources().getString(R.string.navigation_view_header); String titleText = getResources().getString(R.string.navigation_view_header_title); View header = mNavigationView.getHeaderView(0); HeaderView image = header.findViewById(R.id.header_image); LinearLayout container = header.findViewById(R.id.header_title_container); TextView title = header.findViewById(R.id.header_title); TextView version = header.findViewById(R.id.header_version); if (CandyBarApplication.getConfiguration().getNavigationViewHeader() == CandyBarApplication.NavigationViewHeader.MINI) { image.setRatio(16, 9); } if (titleText.length() == 0) { container.setVisibility(View.GONE); } else { title.setText(titleText); try { String versionText = "v" + getPackageManager() .getPackageInfo(getPackageName(), 0).versionName; version.setText(versionText); } catch (Exception ignored) { } } if (ColorHelper.isValidColor(imageUrl)) { image.setBackgroundColor(Color.parseColor(imageUrl)); return; } if (!URLUtil.isValidUrl(imageUrl)) { imageUrl = "drawable://" + DrawableHelper.getResourceId(this, imageUrl); } ImageLoader.getInstance().displayImage(imageUrl, new ImageViewAware(image), ImageConfig.getDefaultImageOptions(true), new ImageSize(720, 720), null, null); }
Example 5
Source File: WallpaperBoardActivity.java From wallpaperboard with Apache License 2.0 | 4 votes |
private void initNavigationViewHeader() { if (WallpaperBoardApplication.getConfig().getNavigationViewHeader() == WallpaperBoardConfiguration.NavigationViewHeader.NONE) { mNavigationView.removeHeaderView(mNavigationView.getHeaderView(0)); return; } String imageUrl = getResources().getString(R.string.navigation_view_header); String titleText = getResources().getString(R.string.navigation_view_header_title); View header = mNavigationView.getHeaderView(0); HeaderView image = header.findViewById(R.id.header_image); LinearLayout container = header.findViewById(R.id.header_title_container); TextView title = header.findViewById(R.id.header_title); TextView version = header.findViewById(R.id.header_version); if (WallpaperBoardApplication.getConfig().getNavigationViewHeader() == WallpaperBoardConfiguration.NavigationViewHeader.MINI) { image.setRatio(16, 9); } if (titleText.length() == 0) { container.setVisibility(View.GONE); } else { title.setText(titleText); try { String versionText = "v" + getPackageManager() .getPackageInfo(getPackageName(), 0).versionName; version.setText(versionText); } catch (Exception ignored) {} } if (ColorHelper.isValidColor(imageUrl)) { image.setBackgroundColor(Color.parseColor(imageUrl)); return; } if (!URLUtil.isValidUrl(imageUrl)) { imageUrl = "drawable://" + DrawableHelper.getResourceId(this, imageUrl); } ImageLoader.getInstance().displayImage(imageUrl, new ImageViewAware(image), ImageConfig.getDefaultImageOptions(), new ImageSize(720, 720), null, null); }
Example 6
Source File: CandyBarMainActivity.java From candybar-library with Apache License 2.0 | 4 votes |
private void initNavigationViewHeader() { if (CandyBarApplication.getConfiguration().getNavigationViewHeader() == CandyBarApplication.NavigationViewHeader.NONE) { mNavigationView.removeHeaderView(mNavigationView.getHeaderView(0)); return; } String imageUrl = getResources().getString(R.string.navigation_view_header); String titleText = getResources().getString(R.string.navigation_view_header_title); View header = mNavigationView.getHeaderView(0); HeaderView image = header.findViewById(R.id.header_image); LinearLayout container = header.findViewById(R.id.header_title_container); TextView title = header.findViewById(R.id.header_title); TextView version = header.findViewById(R.id.header_version); if (CandyBarApplication.getConfiguration().getNavigationViewHeader() == CandyBarApplication.NavigationViewHeader.MINI) { image.setRatio(16, 9); } if (titleText.length() == 0) { container.setVisibility(View.GONE); } else { title.setText(titleText); try { String versionText = "v" + getPackageManager() .getPackageInfo(getPackageName(), 0).versionName; version.setText(versionText); } catch (Exception ignored) {} } if (ColorHelper.isValidColor(imageUrl)) { image.setBackgroundColor(Color.parseColor(imageUrl)); return; } if (!URLUtil.isValidUrl(imageUrl)) { imageUrl = "drawable://" + DrawableHelper.getResourceId(this, imageUrl); } ImageLoader.getInstance().displayImage(imageUrl, new ImageViewAware(image), ImageConfig.getDefaultImageOptions(true), new ImageSize(720, 720), null, null); }
Example 7
Source File: HomeAdapter.java From candybar-library with Apache License 2.0 | 4 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { try { if (holder.itemView != null) { StaggeredGridLayoutManager.LayoutParams layoutParams = (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams(); layoutParams.setFullSpan(isFullSpan(holder.getItemViewType())); } } catch (Exception e) { LogUtil.d(Log.getStackTraceString(e)); } if (holder.getItemViewType() == TYPE_HEADER) { HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder; headerViewHolder.title.setText(mContext.getResources().getString(R.string.home_title)); headerViewHolder.content.setHtml(mContext.getResources().getString(R.string.home_description)); String uri = mContext.getResources().getString(R.string.home_image); if (URLUtil.isValidUrl(uri)) { ImageLoader.getInstance().displayImage(uri, headerViewHolder.image, ImageConfig.getDefaultImageOptions(true)); } else if (ColorHelper.isValidColor(uri)) { headerViewHolder.image.setBackgroundColor(Color.parseColor(uri)); } else { uri = "drawable://" + DrawableHelper.getResourceId(mContext, uri); ImageLoader.getInstance().displayImage(uri, headerViewHolder.image, ImageConfig.getDefaultImageOptions(true)); } } else if (holder.getItemViewType() == TYPE_CONTENT) { ContentViewHolder contentViewHolder = (ContentViewHolder) holder; int finalPosition = position - 1; int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary); if (mHomes.get(finalPosition).getIcon() != -1) { if (mHomes.get(finalPosition).getType() == Home.Type.DIMENSION) { contentViewHolder.autoFitTitle.setCompoundDrawablesWithIntrinsicBounds( DrawableHelper.getResizedDrawable(mContext, DrawableHelper.get(mContext, mHomes.get(finalPosition).getIcon()), 40), null, null, null); } else { contentViewHolder.autoFitTitle.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable( mContext, mHomes.get(finalPosition).getIcon(), color), null, null, null); } } if (mHomes.get(finalPosition).getType() == Home.Type.ICONS) { contentViewHolder.autoFitTitle.setSingleLine(true); contentViewHolder.autoFitTitle.setMaxLines(1); contentViewHolder.autoFitTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources().getDimension(R.dimen.text_max_size)); contentViewHolder.autoFitTitle.setGravity(Gravity.END | Gravity.CENTER_VERTICAL); contentViewHolder.autoFitTitle.setIncludeFontPadding(false); contentViewHolder.autoFitTitle.setSizeToFit(true); contentViewHolder.subtitle.setGravity(Gravity.END | Gravity.CENTER_VERTICAL); } else { contentViewHolder.autoFitTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, mContext.getResources() .getDimension(R.dimen.text_content_title)); } contentViewHolder.autoFitTitle.setText(mHomes.get(finalPosition).getTitle()); if (mHomes.get(finalPosition).getSubtitle().length() > 0) { contentViewHolder.subtitle.setText(mHomes.get(finalPosition).getSubtitle()); contentViewHolder.subtitle.setVisibility(View.VISIBLE); } } else if (holder.getItemViewType() == TYPE_ICON_REQUEST) { IconRequestViewHolder iconRequestViewHolder = (IconRequestViewHolder) holder; int installed = CandyBarMainActivity.sInstalledAppsCount; int missed = CandyBarMainActivity.sMissedApps == null ? installed : CandyBarMainActivity.sMissedApps.size(); int themed = installed - missed; iconRequestViewHolder.installedApps.setText(String.format( mContext.getResources().getString(R.string.home_icon_request_installed_apps), installed)); iconRequestViewHolder.missedApps.setText(String.format( mContext.getResources().getString(R.string.home_icon_request_missed_apps), missed)); iconRequestViewHolder.themedApps.setText(String.format( mContext.getResources().getString(R.string.home_icon_request_themed_apps), themed)); iconRequestViewHolder.progress.setMax(installed); iconRequestViewHolder.progress.setProgress(themed); } else if (holder.getItemViewType() == TYPE_WALLPAPERS) { WallpapersViewHolder wallpapersViewHolder = (WallpapersViewHolder) holder; wallpapersViewHolder.title.setText( String.format(mContext.getResources().getString(R.string.home_loud_wallpapers), Preferences.get(mContext).getAvailableWallpapersCount())); } }