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;
}
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());
}
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());
}
}
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);
}
}
Aggregations