Search in sources :

Example 16 with CardView

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);
    }
}
Also used : Context(android.content.Context) AddressBookEntry(de.schildbach.wallet.addressbook.AddressBookEntry) Dimension(androidx.annotation.Dimension) Wallet(org.bitcoinj.wallet.Wallet) MainThread(androidx.annotation.MainThread) Hashing(com.google.common.hash.Hashing) ColorInt(androidx.annotation.ColorInt) ByteBuffer(java.nio.ByteBuffer) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) MenuInflater(android.view.MenuInflater) Toolbar(android.widget.Toolbar) Map(java.util.Map) Menu(android.view.Menu) View(android.view.View) R(de.schildbach.wallet.R) RecyclerView(androidx.recyclerview.widget.RecyclerView) Constants(de.schildbach.wallet.Constants) CardView(androidx.cardview.widget.CardView) ListAdapter(androidx.recyclerview.widget.ListAdapter) WalletUtils(de.schildbach.wallet.util.WalletUtils) LayoutInflater(android.view.LayoutInflater) DiffUtil(androidx.recyclerview.widget.DiffUtil) Collection(java.util.Collection) ViewGroup(android.view.ViewGroup) StandardCharsets(java.nio.charset.StandardCharsets) ECKey(org.bitcoinj.core.ECKey) Objects(java.util.Objects) List(java.util.List) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Address(org.bitcoinj.core.Address) HashFunction(com.google.common.hash.HashFunction) CardView(androidx.cardview.widget.CardView) Menu(android.view.Menu)

Example 17 with CardView

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;
}
Also used : CardView(androidx.cardview.widget.CardView) RelativeLayout(android.widget.RelativeLayout)

Example 18 with 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;
    }
}
Also used : CardView(androidx.cardview.widget.CardView) Animation(android.view.animation.Animation)

Example 19 with CardView

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;
                    }
                });
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) CaseInsensitiveArrayList(me.ccrama.redditslide.CaseInsensitiveArrayList) CardView(androidx.cardview.widget.CardView) Intent(android.content.Intent) SideArrayAdapter(me.ccrama.redditslide.Adapters.SideArrayAdapter) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) SubmissionsView(me.ccrama.redditslide.Fragments.SubmissionsView) CardView(androidx.cardview.widget.CardView) AutoCompleteTextView(android.widget.AutoCompleteTextView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) KeyEvent(android.view.KeyEvent) ListView(android.widget.ListView) SimpleTextWatcher(me.ccrama.redditslide.util.stubs.SimpleTextWatcher) Editable(android.text.Editable) AutoCompleteTextView(android.widget.AutoCompleteTextView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 20 with CardView

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"));
}
Also used : ViewGroup(android.view.ViewGroup) CardView(androidx.cardview.widget.CardView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) CardView(androidx.cardview.widget.CardView) TypedValue(android.util.TypedValue)

Aggregations

CardView (androidx.cardview.widget.CardView)22 View (android.view.View)17 TextView (android.widget.TextView)13 ViewGroup (android.view.ViewGroup)7 ImageView (android.widget.ImageView)6 Context (android.content.Context)5 Nullable (androidx.annotation.Nullable)5 RecyclerView (androidx.recyclerview.widget.RecyclerView)5 Objects (java.util.Objects)5 NonNull (androidx.annotation.NonNull)3 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 ColorStateList (android.content.res.ColorStateList)2 Drawable (android.graphics.drawable.Drawable)2 Bundle (android.os.Bundle)2 Spannable (android.text.Spannable)2 SpannableString (android.text.SpannableString)2 AttributeSet (android.util.AttributeSet)2 LayoutInflater (android.view.LayoutInflater)2 Menu (android.view.Menu)2