use of android.graphics.drawable.ColorDrawable in project robolectric by robolectric.
the class ShadowTypedArrayTest method getDrawable_withExplicitColorValue_shouldReturnColorDrawable.
@Test
public void getDrawable_withExplicitColorValue_shouldReturnColorDrawable() throws Exception {
TypedArray typedArray = context.obtainStyledAttributes(Robolectric.buildAttributeSet().addAttribute(android.R.attr.background, "#ff777777").build(), new int[] { android.R.attr.background });
assertThat(typedArray.getDrawable(0)).isEqualTo(new ColorDrawable(0xff777777));
}
use of android.graphics.drawable.ColorDrawable in project xabber-android by redsolution.
the class GroupedContactAdapter method getAccountView.
private View getAccountView(int position, View convertView, ViewGroup parent) {
final View view;
final ContactListAccountItemViewHolder viewHolder;
if (convertView == null) {
view = layoutInflater.inflate(R.layout.contact_list_account_group_item, parent, false);
viewHolder = new ContactListAccountItemViewHolder(view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.setElevation(accountElevation);
}
view.setTag(viewHolder);
} else {
view = convertView;
viewHolder = (ContactListAccountItemViewHolder) view.getTag();
}
final AccountConfiguration configuration = (AccountConfiguration) getItem(position);
final String account = configuration.getAccount();
viewHolder.statusIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onClickListener.onAccountMenuClick(v, account);
}
});
final int level = AccountManager.getInstance().getColorLevel(account);
view.setBackgroundDrawable(new ColorDrawable(accountGroupColors[level]));
viewHolder.name.setText(GroupManager.getInstance().getGroupName(account, configuration.getUser()));
viewHolder.smallRightText.setText(configuration.getOnline() + "/" + configuration.getTotal());
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
String statusText = accountItem.getStatusText().trim();
if (statusText.isEmpty()) {
statusText = activity.getString(accountItem.getDisplayStatusMode().getStringID());
}
viewHolder.secondLineMessage.setText(statusText);
if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
} else {
viewHolder.avatar.setVisibility(View.GONE);
}
viewHolder.avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.startActivity(AccountViewer.createAccountInfoIntent(activity, account));
}
});
viewHolder.statusIcon.setImageLevel(accountItem.getDisplayStatusMode().getStatusLevel());
ShowOfflineMode showOfflineMode = configuration.getShowOfflineMode();
if (showOfflineMode == ShowOfflineMode.normal) {
if (SettingsManager.contactsShowOffline()) {
showOfflineMode = ShowOfflineMode.always;
} else {
showOfflineMode = ShowOfflineMode.never;
}
}
viewHolder.smallRightIcon.setImageLevel(showOfflineMode.ordinal());
StatusMode statusMode = AccountManager.getInstance().getAccount(configuration.getAccount()).getDisplayStatusMode();
if (statusMode == StatusMode.unavailable || statusMode == StatusMode.connection) {
viewHolder.offlineShadow.setVisibility(View.VISIBLE);
} else {
viewHolder.offlineShadow.setVisibility(View.GONE);
}
return view;
}
use of android.graphics.drawable.ColorDrawable in project picasso by square.
the class RequestCreatorTest method invalidErrorImage.
@Test
public void invalidErrorImage() {
try {
new RequestCreator().error(0);
fail("Resource ID of zero should throw exception.");
} catch (IllegalArgumentException ignored) {
}
try {
new RequestCreator().error(null);
fail("Null drawable should throw exception.");
} catch (IllegalArgumentException ignored) {
}
try {
new RequestCreator().error(1).error(new ColorDrawable(0));
fail("Two placeholders should throw exception.");
} catch (IllegalStateException ignored) {
}
try {
new RequestCreator().error(new ColorDrawable(0)).error(1);
fail("Two placeholders should throw exception.");
} catch (IllegalStateException ignored) {
}
}
use of android.graphics.drawable.ColorDrawable in project picasso by square.
the class RequestCreatorTest method invalidNoPlaceholder.
@Test
public void invalidNoPlaceholder() {
try {
new RequestCreator().noPlaceholder().placeholder(new ColorDrawable(0));
fail("Placeholder after no placeholder should throw exception.");
} catch (IllegalStateException ignored) {
}
try {
new RequestCreator().noPlaceholder().placeholder(1);
fail("Placeholder after no placeholder should throw exception.");
} catch (IllegalStateException ignored) {
}
try {
new RequestCreator().placeholder(1).noPlaceholder();
fail("No placeholder after placeholder should throw exception.");
} catch (IllegalStateException ignored) {
}
try {
new RequestCreator().placeholder(new ColorDrawable(0)).noPlaceholder();
fail("No placeholder after placeholder should throw exception.");
} catch (IllegalStateException ignored) {
}
}
use of android.graphics.drawable.ColorDrawable in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class RentalsStyleFragment method createView.
@Override
protected View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_materail_style, null);
setHeaderTitle(R.string.ptr_demo_rentals_style);
final CubeImageView imageView = (CubeImageView) view.findViewById(R.id.material_style_image_view);
final ImageLoader imageLoader = ImageLoaderFactory.create(getContext());
final PtrFrameLayout frame = (PtrFrameLayout) view.findViewById(R.id.material_style_ptr_frame);
// header
final RentalsSunHeaderView header = new RentalsSunHeaderView(getContext());
header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
header.setPadding(0, LocalDisplay.dp2px(15), 0, LocalDisplay.dp2px(10));
header.setUp(frame);
frame.setLoadingMinTime(1000);
frame.setDurationToCloseHeader(1500);
frame.setHeaderView(header);
frame.addPtrUIHandler(header);
// frame.setPullToRefresh(true);
frame.postDelayed(new Runnable() {
@Override
public void run() {
frame.autoRefresh(true);
}
}, 100);
frame.setPtrHandler(new PtrHandler() {
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return true;
}
@Override
public void onRefreshBegin(final PtrFrameLayout frame) {
if (mImageHasLoaded) {
long delay = 1500;
frame.postDelayed(new Runnable() {
@Override
public void run() {
frame.refreshComplete();
}
}, delay);
} else {
mStartLoadingTime = System.currentTimeMillis();
imageView.loadImage(imageLoader, mUrl);
}
}
});
ImageLoadHandler imageLoadHandler = new ImageLoadHandler() {
@Override
public void onLoading(ImageTask imageTask, CubeImageView cubeImageView) {
}
@Override
public void onLoadFinish(ImageTask imageTask, final CubeImageView cubeImageView, final BitmapDrawable bitmapDrawable) {
mImageHasLoaded = true;
long delay = 1500;
frame.postDelayed(new Runnable() {
@Override
public void run() {
if (cubeImageView != null && bitmapDrawable != null) {
TransitionDrawable w1 = new TransitionDrawable(new Drawable[] { new ColorDrawable(Color.WHITE), (Drawable) bitmapDrawable });
imageView.setImageDrawable(w1);
w1.startTransition(200);
}
frame.refreshComplete();
}
}, delay);
}
@Override
public void onLoadError(ImageTask imageTask, CubeImageView cubeImageView, int i) {
}
};
imageLoader.setImageLoadHandler(imageLoadHandler);
return view;
}
Aggregations