use of androidx.cardview.widget.CardView in project bitcoin-wallet by bitcoin-wallet.
the class AddressBookAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
final ListItem listItem = getItem(position);
if (holder instanceof AddressViewHolder) {
final AddressViewHolder addressHolder = (AddressViewHolder) holder;
final ListItem.AddressItem addressItem = (ListItem.AddressItem) listItem;
addressHolder.label.setText(addressItem.label != null ? addressItem.label : labelUnlabeled);
addressHolder.label.setTextColor(addressItem.labelColor);
addressHolder.address.setText(WalletUtils.formatAddress(addressItem.address, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE));
addressHolder.address.setTextColor(addressItem.addressColor);
addressHolder.message.setVisibility(addressItem.message != null ? View.VISIBLE : View.GONE);
addressHolder.message.setText(addressItem.message);
addressHolder.message.setTextColor(addressItem.messageColor);
final boolean isSelected = addressItem.address.equals(selectedAddress);
addressHolder.itemView.setSelected(isSelected);
((CardView) addressHolder.itemView).setCardElevation(isSelected ? cardElevationSelected : 0);
if (onClickListener != null)
addressHolder.itemView.setOnClickListener(v -> onClickListener.onAddressClick(v, addressItem.address, addressItem.label));
addressHolder.contextBar.setVisibility(View.GONE);
if (contextMenuCallback != null && isSelected) {
final Menu menu = addressHolder.contextBar.getMenu();
menu.clear();
contextMenuCallback.onInflateAddressContextMenu(menuInflater, menu);
if (menu.hasVisibleItems()) {
addressHolder.contextBar.setVisibility(View.VISIBLE);
addressHolder.contextBar.setOnMenuItemClickListener(item -> contextMenuCallback.onClickAddressContextMenuItem(item, addressItem.address, addressItem.label));
}
}
} else if (holder instanceof SeparatorViewHolder) {
final SeparatorViewHolder separatorHolder = (SeparatorViewHolder) holder;
final ListItem.SeparatorItem separatorItem = (ListItem.SeparatorItem) listItem;
separatorHolder.label.setText(separatorItem.label);
}
}
use of androidx.cardview.widget.CardView in project OneSignal-Android-SDK by OneSignal.
the class InAppMessageView method createCardView.
/**
* To show drop shadow on WebView
* Layout container for WebView is needed
*/
private CardView createCardView(Context context) {
CardView cardView = new CardView(context);
int height = displayLocation == WebViewManager.Position.FULL_SCREEN ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
RelativeLayout.LayoutParams cardViewLayoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height);
cardViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
cardView.setLayoutParams(cardViewLayoutParams);
// Fixes bug when animating a elevated CardView class
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M)
cardView.setCardElevation(0);
else
cardView.setCardElevation(dpToPx(5));
cardView.setRadius(dpToPx(8));
cardView.setClipChildren(false);
cardView.setClipToPadding(false);
cardView.setPreventCornerOverlap(false);
cardView.setCardBackgroundColor(Color.TRANSPARENT);
return cardView;
}
use of androidx.cardview.widget.CardView in project OneSignal-Android-SDK by OneSignal.
the class InAppMessageView method animateInAppMessage.
private void animateInAppMessage(WebViewManager.Position displayLocation, View messageView, View backgroundView) {
final CardView messageViewCardView = messageView.findViewWithTag(IN_APP_MESSAGE_CARD_VIEW_TAG);
Animation.AnimationListener cardViewAnimCallback = createAnimationListener(messageViewCardView);
// Based on the location of the in app message apply and animation to match
switch(displayLocation) {
case TOP_BANNER:
animateTop(messageViewCardView, webView.getHeight(), cardViewAnimCallback);
break;
case BOTTOM_BANNER:
animateBottom(messageViewCardView, webView.getHeight(), cardViewAnimCallback);
break;
case CENTER_MODAL:
case FULL_SCREEN:
animateCenter(messageView, backgroundView, cardViewAnimCallback, null);
break;
}
}
use of androidx.cardview.widget.CardView in project Slide by ccrama.
the class MainActivity method setupSubredditSearchToolbar.
/**
* If the user has the Subreddit Search method set to "long press on toolbar title", an
* OnLongClickListener needs to be set for the toolbar as well as handling all of the relevant
* onClicks for the views of the search bar.
*/
private void setupSubredditSearchToolbar() {
if (!NetworkUtil.isConnected(this)) {
if (findViewById(R.id.drawer_divider) != null) {
findViewById(R.id.drawer_divider).setVisibility(View.GONE);
}
} else {
if ((SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_TOOLBAR || SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) && usedArray != null && !usedArray.isEmpty()) {
if (findViewById(R.id.drawer_divider) != null) {
if (SettingValues.subredditSearchMethod == Constants.SUBREDDIT_SEARCH_METHOD_BOTH) {
findViewById(R.id.drawer_divider).setVisibility(View.GONE);
} else {
findViewById(R.id.drawer_divider).setVisibility(View.VISIBLE);
}
}
final ListView TOOLBAR_SEARCH_SUGGEST_LIST = (ListView) findViewById(R.id.toolbar_search_suggestions_list);
final ArrayList<String> subs_copy = new ArrayList<>(usedArray);
final SideArrayAdapter TOOLBAR_SEARCH_SUGGEST_ADAPTER = new SideArrayAdapter(this, subs_copy, UserSubscriptions.getAllSubreddits(this), TOOLBAR_SEARCH_SUGGEST_LIST);
if (TOOLBAR_SEARCH_SUGGEST_LIST != null) {
TOOLBAR_SEARCH_SUGGEST_LIST.setAdapter(TOOLBAR_SEARCH_SUGGEST_ADAPTER);
}
if (mToolbar != null) {
mToolbar.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
final AutoCompleteTextView GO_TO_SUB_FIELD = (AutoCompleteTextView) findViewById(R.id.toolbar_search);
final ImageView CLOSE_BUTTON = (ImageView) findViewById(R.id.close_search_toolbar);
final CardView SUGGESTIONS_BACKGROUND = (CardView) findViewById(R.id.toolbar_search_suggestions);
// if the view mode is set to Subreddit Tabs, save the title ("Slide" or "Slide (debug)")
tabViewModeTitle = (!SettingValues.single) ? getSupportActionBar().getTitle().toString() : null;
getSupportActionBar().setTitle(// clear title to make room for search field
"");
if (GO_TO_SUB_FIELD != null && CLOSE_BUTTON != null && SUGGESTIONS_BACKGROUND != null) {
GO_TO_SUB_FIELD.setVisibility(View.VISIBLE);
CLOSE_BUTTON.setVisibility(View.VISIBLE);
SUGGESTIONS_BACKGROUND.setVisibility(View.VISIBLE);
// run enter animations
enterAnimationsForToolbarSearch(ANIMATE_DURATION, SUGGESTIONS_BACKGROUND, GO_TO_SUB_FIELD, CLOSE_BUTTON);
// Get focus of the search field and show the keyboard
GO_TO_SUB_FIELD.requestFocus();
KeyboardUtil.toggleKeyboard(MainActivity.this, InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
// Close the search UI and keyboard when clicking the close button
CLOSE_BUTTON.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final View view = MainActivity.this.getCurrentFocus();
if (view != null) {
// Hide the keyboard
KeyboardUtil.hideKeyboard(MainActivity.this, view.getWindowToken(), 0);
}
// run the exit animations
exitAnimationsForToolbarSearch(ANIMATE_DURATION, SUGGESTIONS_BACKGROUND, GO_TO_SUB_FIELD, CLOSE_BUTTON);
// clear sub text when close button is clicked
GO_TO_SUB_FIELD.setText("");
}
});
GO_TO_SUB_FIELD.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
if (arg1 == EditorInfo.IME_ACTION_SEARCH) {
// If it the input text doesn't match a subreddit from the list exactly, openInSubView is true
if (sideArrayAdapter.fitems == null || sideArrayAdapter.openInSubView || !usedArray.contains(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH))) {
Intent intent = new Intent(MainActivity.this, SubredditView.class);
intent.putExtra(SubredditView.EXTRA_SUBREDDIT, GO_TO_SUB_FIELD.getText().toString());
MainActivity.this.startActivityForResult(intent, 2002);
} else {
if (commentPager && adapter instanceof MainPagerAdapterComment) {
openingComments = null;
toOpenComments = -1;
((MainPagerAdapterComment) adapter).size = (usedArray.size() + 1);
adapter.notifyDataSetChanged();
if (usedArray.contains(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH))) {
doPageSelectedComments(usedArray.indexOf(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH)));
} else {
doPageSelectedComments(usedArray.indexOf(sideArrayAdapter.fitems.get(0)));
}
}
if (usedArray.contains(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH))) {
pager.setCurrentItem(usedArray.indexOf(GO_TO_SUB_FIELD.getText().toString().toLowerCase(Locale.ENGLISH)));
} else {
pager.setCurrentItem(usedArray.indexOf(sideArrayAdapter.fitems.get(0)));
}
}
View view = MainActivity.this.getCurrentFocus();
if (view != null) {
// Hide the keyboard
KeyboardUtil.hideKeyboard(MainActivity.this, view.getWindowToken(), 0);
}
SUGGESTIONS_BACKGROUND.setVisibility(View.GONE);
GO_TO_SUB_FIELD.setVisibility(View.GONE);
CLOSE_BUTTON.setVisibility(View.GONE);
if (SettingValues.single) {
getSupportActionBar().setTitle(selectedSub);
} else {
// Set the title back to "Slide" or "Slide (debug)"
getSupportActionBar().setTitle(tabViewModeTitle);
}
}
return false;
}
});
GO_TO_SUB_FIELD.addTextChangedListener(new SimpleTextWatcher() {
@Override
public void afterTextChanged(Editable editable) {
final String RESULT = GO_TO_SUB_FIELD.getText().toString().replaceAll(" ", "");
TOOLBAR_SEARCH_SUGGEST_ADAPTER.getFilter().filter(RESULT);
}
});
}
return true;
}
});
}
}
}
}
use of androidx.cardview.widget.CardView in project Slide by ccrama.
the class CreateCardView method resetColorCard.
public static void resetColorCard(View v) {
v.setTag(v.getId(), "none");
TypedValue background = new TypedValue();
v.getContext().getTheme().resolveAttribute(R.attr.card_background, background, true);
((CardView) v.findViewById(R.id.card)).setCardBackgroundColor(background.data);
if (!SettingValues.actionbarVisible) {
for (View v2 : getViewsByTag((ViewGroup) v, "tintactionbar")) {
v2.setVisibility(View.GONE);
}
}
doColor(getViewsByTag((ViewGroup) v, "tint"));
doColorSecond(getViewsByTag((ViewGroup) v, "tintsecond"));
doColorSecond(getViewsByTag((ViewGroup) v, "tintactionbar"));
}
Aggregations