Search in sources :

Example 11 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project ods-android by Orange-OpenSource.

the class CardSwipeDismissFragment method onCreateDemoView.

/**
 * Inflate fragment view and setup with {@link SwipeDismissBehavior}
 */
@Override
public View onCreateDemoView(LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
    View view = layoutInflater.inflate(R.layout.cat_card_swipe_fragment, viewGroup, false);
    CoordinatorLayout container = view.findViewById(R.id.card_container);
    SwipeDismissBehavior<View> swipeDismissBehavior = new SwipeDismissBehavior<>();
    swipeDismissBehavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
    MaterialCardView cardContentLayout = view.findViewById(R.id.card_content_layout);
    CoordinatorLayout.LayoutParams coordinatorParams = (CoordinatorLayout.LayoutParams) cardContentLayout.getLayoutParams();
    coordinatorParams.setBehavior(swipeDismissBehavior);
    swipeDismissBehavior.setListener(new OnDismissListener() {

        @Override
        public void onDismiss(View view) {
            Snackbar.make(container, R.string.cat_card_dismissed, Snackbar.LENGTH_INDEFINITE).setAction(R.string.cat_card_undo, v -> resetCard(cardContentLayout)).show();
        }

        @Override
        public void onDragStateChanged(int state) {
            CardSwipeDismissFragment.onDragStateChanged(state, cardContentLayout);
        }
    });
    return view;
}
Also used : CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) MaterialCardView(com.google.android.material.card.MaterialCardView) SwipeDismissBehavior(com.google.android.material.behavior.SwipeDismissBehavior) OnDismissListener(com.google.android.material.behavior.SwipeDismissBehavior.OnDismissListener) MaterialCardView(com.google.android.material.card.MaterialCardView) View(android.view.View)

Example 12 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project luckyzyxtools by luckyzyx.

the class HomeFragment method onViewCreated.

@SuppressLint({ "SetTextI18n", "InflateParams" })
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    // Xposed
    MaterialTextView xposed_info = requireActivity().findViewById(R.id.xposed_info);
    xposed_info.setText("版本: " + BuildConfig.VERSION_NAME + "\n版本号: " + BuildConfig.VERSION_CODE);
    // Button
    MaterialButton xposed = requireActivity().findViewById(R.id.xposed_btn);
    xposed.setOnClickListener(v -> startActivity(new Intent(requireActivity(), XposedActivity.class)));
    MaterialButton magisk = requireActivity().findViewById(R.id.magisk_btn);
    magisk.setOnClickListener(v -> startActivity(new Intent(requireActivity(), MagiskActivity.class)));
    MaterialButton fps = requireActivity().findViewById(R.id.fps);
    fps.setOnClickListener(v -> MainActivity.setfps(requireActivity()));
    MaterialCardView updatelog_card = requireActivity().findViewById(R.id.updatelog_card);
    updatelog_card.setOnClickListener(v -> new UpdateLog(requireActivity()).ShowUpdateLog());
    TextView systeminfo = requireActivity().findViewById(R.id.systeminfo);
    systeminfo.setText(getSystemInfo());
}
Also used : MaterialTextView(com.google.android.material.textview.MaterialTextView) MaterialCardView(com.google.android.material.card.MaterialCardView) UpdateLog(com.luckyzyx.tools.utils.UpdateLog) Intent(android.content.Intent) MaterialTextView(com.google.android.material.textview.MaterialTextView) TextView(android.widget.TextView) MaterialButton(com.google.android.material.button.MaterialButton) SuppressLint(android.annotation.SuppressLint)

Example 13 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project material-about-library by daniel-stoneuk.

the class MaterialAboutListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(MaterialAboutListViewHolder holder, int position) {
    MaterialAboutCard card = differ.getCurrentList().get(position);
    if (holder.cardView instanceof CardView) {
        CardView cardView = (CardView) holder.cardView;
        int cardColor = card.getCardColor();
        if (cardColor != 0) {
            cardView.setCardBackgroundColor(cardColor);
        } else {
            cardView.setCardBackgroundColor(cardView.getCardBackgroundColor().getDefaultColor());
        }
    }
    CharSequence title = card.getTitle();
    int titleRes = card.getTitleRes();
    holder.title.setVisibility(View.VISIBLE);
    if (title != null) {
        holder.title.setText(title);
    } else if (titleRes != 0) {
        holder.title.setText(titleRes);
    } else {
        holder.title.setVisibility(View.GONE);
    }
    int titleColor = card.getTitleColor();
    if (holder.title.getVisibility() == View.VISIBLE) {
        if (titleColor != 0) {
            holder.title.setTextColor(titleColor);
        } else {
            holder.title.setTextColor(holder.title.getTextColors().getDefaultColor());
        }
    }
    if (holder.cardView instanceof MaterialCardView) {
        MaterialCardView materialCardView = (MaterialCardView) holder.cardView;
        if (card.isOutline()) {
            materialCardView.setStrokeWidth((int) context.getResources().getDimension(R.dimen.mal_stroke_width));
            materialCardView.setCardElevation(0);
        } else {
            materialCardView.setStrokeWidth(0);
            materialCardView.setCardElevation(context.getResources().getDimension(R.dimen.mal_card_elevation));
        }
    }
    if (card.getCustomAdapter() != null) {
        holder.useCustomAdapter(card.getCustomAdapter());
    } else {
        holder.useMaterialAboutItemAdapter();
        ((MaterialAboutItemAdapter) holder.adapter).setData(card.getItems());
    }
}
Also used : MaterialCardView(com.google.android.material.card.MaterialCardView) MaterialAboutCard(com.danielstone.materialaboutlibrary.model.MaterialAboutCard) MaterialCardView(com.google.android.material.card.MaterialCardView) CardView(androidx.cardview.widget.CardView)

Example 14 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project doodle-android by patzly.

the class AppearanceFragment method refreshColor.

private void refreshColor(int priority, boolean animated) {
    if (binding == null || currentWallpaper == null || currentVariant == null) {
        return;
    }
    String colorHex = null;
    if (getSharedPrefs() != null) {
        colorHex = getSharedPrefs().getString(Constants.getThemeColorPref(currentWallpaper.getName(), currentVariantIndex, priority, isWallpaperNightMode()), currentVariant.getColorHex(priority));
    }
    int color;
    if (colorHex != null) {
        color = Color.parseColor(colorHex);
    } else {
        color = currentVariant.getColor(priority);
    }
    MaterialCardView card = (MaterialCardView) binding.linearAppearanceColorsContainer.getChildAt(priority);
    if (card == null) {
        return;
    }
    if (animated) {
        ValueAnimator animator = ValueAnimator.ofArgb(card.getCardBackgroundColor().getDefaultColor(), color);
        animator.addUpdateListener(animation -> card.setCardBackgroundColor((int) animation.getAnimatedValue()));
        animator.setDuration(300);
        animator.setInterpolator(new FastOutSlowInInterpolator());
        animator.start();
    } else {
        card.setCardBackgroundColor(color);
    }
}
Also used : MaterialCardView(com.google.android.material.card.MaterialCardView) FastOutSlowInInterpolator(androidx.interpolator.view.animation.FastOutSlowInInterpolator) ValueAnimator(android.animation.ValueAnimator) SuppressLint(android.annotation.SuppressLint)

Aggregations

MaterialCardView (com.google.android.material.card.MaterialCardView)14 View (android.view.View)8 Intent (android.content.Intent)6 TextView (android.widget.TextView)6 SuppressLint (android.annotation.SuppressLint)4 EditText (android.widget.EditText)4 AlertDialog (androidx.appcompat.app.AlertDialog)4 CardView (androidx.cardview.widget.CardView)4 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)4 Uri (android.net.Uri)3 Button (android.widget.Button)3 ImageView (android.widget.ImageView)3 ListView (android.widget.ListView)3 ClipData (android.content.ClipData)2 ClipboardManager (android.content.ClipboardManager)2 Bundle (android.os.Bundle)2 Spannable (android.text.Spannable)2 SpannableString (android.text.SpannableString)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 Spanned (android.text.Spanned)2