androidx.cardview.widget.CardView Java Examples

The following examples show how to use androidx.cardview.widget.CardView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TagAdapter.java    From kolabnotes-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ViewHolder(View itemView, final ClickListener listener, final List<Tag> tags) {
    super(itemView);
    this.tags = tags;
    this.listener = listener;

    itemView.setOnClickListener(this);
    itemView.setOnLongClickListener(this);

    tagName = (TextView) itemView.findViewById(R.id.tagName);
    tagCreatedDate = (TextView) itemView.findViewById(R.id.tagCreatedDate);
    tagModificationDate = (TextView) itemView.findViewById(R.id.tagModificationDate);
    tagColor = itemView.findViewById(R.id.tagColor);
    tagColor.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (listener != null) {
                listener.onColorPickerClicked(getAdapterPosition(), tags.get(getAdapterPosition()));
            }
        }
    });
    tagHolder = (CardView) itemView;
}
 
Example #2
Source File: BlackWhiteListActivity.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
@CallSuper
@Override
public void updateUiElements() {
    super.updateUiElements();
    toolbar.setBackgroundColor(getPrimaryColor());
    mRecyclerView.setBackgroundColor(getBackgroundColor());
    setStatusBarColor();
    setNavBarColor();
    toolbar.setTitle(getTitle());
    setRecentApp(getTitle().toString());
    ((CardView) findViewById(R.id.white_list_decription_card)).setCardBackgroundColor(getCardBackgroundColor());
    ((TextView) findViewById(R.id.white_list_decription_txt)).setTextColor(getTextColor());
    //TODO: EMOJI EASTER EGG - THERE'S NOTHING TO SHOW
    ((TextView) findViewById(R.id.emoji_easter_egg)).setTextColor(getSubTextColor());
    ((TextView) findViewById(R.id.nothing_to_show_text_emoji_easter_egg)).setTextColor(getSubTextColor());

    findViewById(com.alienpants.leafpicrevived.R.id.rl_ea).setBackgroundColor(getBackgroundColor());
}
 
Example #3
Source File: MainActivity.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportActionBar().setTitle("Whats the weather?");
    tv_city = findViewById(R.id.tv_city);
    btn_go = findViewById(R.id.btn_go);
    myurl = null;
    tv_temp = findViewById(R.id.tv_temp);
    tv_desc = findViewById(R.id.tv_desc);
    tv_humid = findViewById(R.id.tv_humid);
    cd = (CardView)findViewById(R.id.card_view);
    pd = new ProgressDialog(MainActivity.this);
    pd.setMessage("Fetching the weather");
    animFadein = AnimationUtils.loadAnimation(getApplicationContext(),
            R.anim.fade_in);
    front_image = findViewById(R.id.front_image);
    front_image.setAnimation(animFadein);
    cd.setAnimation(animFadein);

}
 
Example #4
Source File: PaletteActivity.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
@CallSuper
@Override
public void updateUiElements() {
    super.updateUiElements();

    toolbar.setBackgroundColor(getPrimaryColor());
    toolbar.setNavigationIcon(getToolbarIcon(GoogleMaterial.Icon.gmd_arrow_back));
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    setStatusBarColor();
    setNavBarColor();
    setRecentApp(getString(R.string.palette));

    findViewById(R.id.palette_background).setBackgroundColor(getBackgroundColor());
    ((CardView) findViewById(R.id.palette_colors_card)).setCardBackgroundColor(getCardBackgroundColor());
    ((CardView) findViewById(R.id.palette_image_card)).setCardBackgroundColor(getCardBackgroundColor());
    ((TextView) findViewById(R.id.palette_image_title)).setTextColor(getTextColor());
    ((TextView) findViewById(R.id.palette_image_caption)).setTextColor(getSubTextColor());
}
 
Example #5
Source File: CurrencyCardAdapter.java    From adamant-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(container.getContext())
            .inflate(R.layout.list_item_wallet_card, container, false);
    container.addView(view);
    bind(items.get(position), view);
    CardView cardView = (CardView) view.findViewById(R.id.list_item_wallet_card_cv_card);

    if (mBaseElevation == 0) {
        mBaseElevation = cardView.getCardElevation();
    }

    cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
    if (position < views.size()){
        views.set(position, cardView);
    } else {
        views.add(cardView);
    }
    return view;
}
 
Example #6
Source File: RecordArrayAdapter.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void showEditorDialog(Record record, int position, ViewHolder viewHolder) {
    RecordEditorDialogbox recordEditorDialogbox = new RecordEditorDialogbox(mActivity, record, mDisplayType==DisplayType.PROGRAM_EDIT_DISPLAY);
    recordEditorDialogbox.setOnCancelListener(dialog -> {
        if (mDisplayType==DisplayType.PROGRAM_RUNNING_DISPLAY) record.setProgramRecordStatus(ProgramRecordStatus.PENDING);
        mDbRecord.updateRecord(record);
        UpdateRecordTypeUI(record, viewHolder);
        UpdateValues(record, position, viewHolder);
        notifyDataSetChanged();
        Keyboard.hide(getContext(), viewHolder.CardView);
    });
    recordEditorDialogbox.setOnDismissListener(dialog -> {
        notifyDataSetChanged();
        Keyboard.hide(getContext(), viewHolder.CardView);
    });
    recordEditorDialogbox.show();
}
 
Example #7
Source File: GenerateActivity.java    From SecScanQR with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Standard Android on create method that gets called when the activity
 * initialized.
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    generalHandler = new GeneralHandler(this);
    generalHandler.loadTheme();
    setContentView(R.layout.activity_generate);
    barcodeCard = (CardView) findViewById(R.id.barcode_card);
    textCard = (CardView) findViewById(R.id.text_card);
    geoCard = (CardView) findViewById(R.id.geo_card);
    contactCard = (CardView) findViewById(R.id.contact_card);
    wifiCard = (CardView) findViewById(R.id.wifi_card);

    barcodeCard.setOnClickListener(this);
    textCard.setOnClickListener(this);
    geoCard.setOnClickListener(this);
    contactCard.setOnClickListener(this);
    wifiCard.setOnClickListener(this);
}
 
Example #8
Source File: AlarmTopCardItemView.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
public AlarmTopCardItemView(View view) {
    super(view);
    context = view.getContext();
    mDashedCircleView = (DashedCircleView) view.findViewById(R.id.dashed_circle);

    mCenterTopTextView = (Version1TextView) view.findViewById(R.id.center_top_text);
    mCenterBottomTextView = (Version1TextView) view.findViewById(R.id.center_bottom_text);

    mTopIconView = (ImageView) view.findViewById(R.id.top_icon);
    mTopLineView = view.findViewById(R.id.top_line);
    mLeftAlarmIcon = (ImageView) view.findViewById(R.id.left_alarm_icon);
    mCenterAlarmText = (Version1TextView) view.findViewById(R.id.center_alarm_text);
    mRightAlarmIcon = (ImageView) view.findViewById(R.id.right_alarm_icon);
    placeName = (Version1TextView) view.findViewById(R.id.place_name);
    placeAddress = (Version1TextView) view.findViewById(R.id.place_address);
    cardView = (CardView) view.findViewById(R.id.cardView);
    placeLayout = view.findViewById(R.id.place_layout);
    topDivider = view.findViewById(R.id.topdivider);
    careOnOffView = view.findViewById(R.id.care_on_off_toggle_container);
    toggleButton = (ToggleButton) view.findViewById(R.id.care_on_off_toggle);
}
 
Example #9
Source File: SwipeBehaviorExampleActivity.java    From CoordinatorExamples with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_swipe_behavior);


	final SwipeDismissBehavior swipe = new SwipeDismissBehavior();
	swipe.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_ANY);
	swipe.setListener(new SwipeDismissBehavior.OnDismissListener() {
		@Override public void onDismiss(View view) {
			Toast.makeText(SwipeBehaviorExampleActivity.this,
				"Card swiped !!", Toast.LENGTH_SHORT).show();
		}

		@Override public void onDragStateChanged(int state) {}
	});

	CardView cardView = (CardView) findViewById(R.id.swype_card);
	LayoutParams coordinatorParams = (LayoutParams) cardView.getLayoutParams();
	coordinatorParams.setBehavior(swipe);
}
 
Example #10
Source File: QuizActivity.java    From memorize with MIT License 6 votes vote down vote up
CardView getCorrectCardView(int indexRightAnswer) {
    String rightAnswerTag = String.valueOf(indexRightAnswer);

    if (cardAnswer1.getTag().equals(rightAnswerTag)) {
        return cardAnswer1;

    } else if (cardAnswer2.getTag().equals(rightAnswerTag)) {
        return cardAnswer2;

    } else if (cardAnswer3.getTag().equals(rightAnswerTag)) {
        return cardAnswer3;

    } else if (cardAnswer4.getTag().equals(rightAnswerTag)) {
        return cardAnswer4;
    }

    return null;
}
 
Example #11
Source File: MapLayerListFragment.java    From geopaparazzi with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onBindDragView(View clickedView, View dragView) {
    CharSequence name = ((TextView) clickedView.findViewById(R.id.nameView)).getText();
    ((TextView) dragView.findViewById(R.id.nameView)).setText(name);

    CharSequence path = ((TextView) clickedView.findViewById(R.id.pathView)).getText();
    ((TextView) dragView.findViewById(R.id.pathView)).setText(path);

    boolean enabled = ((CheckBox) clickedView.findViewById(R.id.enableCheckbox)).isChecked();
    ((CheckBox) dragView.findViewById(R.id.enableCheckbox)).setChecked(enabled);

    CardView dragCard = dragView.findViewById(R.id.card);
    CardView clickedCard = clickedView.findViewById(R.id.card);

    dragCard.setMaxCardElevation(40);
    dragCard.setCardElevation(clickedCard.getCardElevation());
    // I know the dragView is a FrameLayout and that is why I can use setForeground below api level 23
    dragCard.setForeground(clickedView.getResources().getDrawable(R.drawable.card_view_drag_foreground));
}
 
Example #12
Source File: AlertDialogsHelper.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
public static AlertDialog getAlbumDetailsDialog(final ThemedActivity activity, final Album album, final AlbumsAdapter adapter) {
    AlertDialog.Builder detailsDialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
    MetadataHelper mdHelper = new MetadataHelper();
    MediaDetailsMap<String, String> mainAlbumDetails;
    if (adapter.getSelectedCount() > 1) {
        mainAlbumDetails = mdHelper.getSelectedAlbumsDetails(activity, adapter);
    } else {
        mainAlbumDetails = mdHelper.getFirstSelectedAlbumDetails(activity, album);
    }
    final View dialogLayout = activity.getLayoutInflater().inflate(com.alienpants.leafpicrevived.R.layout.dialog_media_detail, null);
    dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.details_title).setBackgroundColor(activity.getPrimaryColor());
    ((CardView) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.photo_details_card)).setCardBackgroundColor(activity.getCardBackgroundColor());

    detailsDialogBuilder.setView(dialogLayout);
    loadDetails(dialogLayout, activity, mainAlbumDetails);
    return detailsDialogBuilder.create();
}
 
Example #13
Source File: Recolor.java    From Mysplash with GNU Lesser General Public License v3.0 6 votes vote down vote up
@ColorInt
private static int getBackgroundColor(View view) {
    int color = Color.TRANSPARENT;
    if (view instanceof CardView) {
        color = ((CardView) view).getCardBackgroundColor().getDefaultColor();
    } else {
        Drawable d = view.getBackground();
        if (d instanceof ColorDrawable) {
            color = ((ColorDrawable) d).getColor();
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
                && d instanceof ColorStateListDrawable) {
            color = ((ColorStateListDrawable) d).getColorStateList().getDefaultColor();
        }
    }
    return color;
}
 
Example #14
Source File: NoteAdapter.java    From kolabnotes-android with GNU Lesser General Public License v3.0 6 votes vote down vote up
public ViewHolder(View itemView, ClickListener listener, List<Note> notes) {
    super(itemView);

    this.notes = notes;
    this.listener = listener;

    itemView.setOnClickListener(this);
    itemView.setOnLongClickListener(this);

    name = (TextView) itemView.findViewById(R.id.noteSummary);
    classification = (TextView) itemView.findViewById(R.id.classification);
    createdDate = (TextView) itemView.findViewById(R.id.createdDate);
    modificationDate = (TextView) itemView.findViewById(R.id.modificationDate);
    categories = (LinearLayout) itemView.findViewById(R.id.categories);
    cardView = (CardView)itemView;
    attachmentImage = (ImageView)itemView.findViewById(R.id.attachmentHint);
    notePreview = (TextView)itemView.findViewById(R.id.notePreview);
}
 
Example #15
Source File: TimeCursorAdapter.java    From TwistyTimer with GNU General Public License v3.0 6 votes vote down vote up
private void toggleSelection(long id, CardView card) {
    if (! isSelected(id)) {
        broadcast(CATEGORY_UI_INTERACTIONS, ACTION_TIME_SELECTED);
        selectedItems.add(id);
        card.setBackground(selectedCardBackground);
    } else {
        broadcast(CATEGORY_UI_INTERACTIONS, ACTION_TIME_UNSELECTED);
        selectedItems.remove(id);
        card.setBackground(cardBackground);
    }

    if (selectedItems.size() == 0) {
        broadcast(CATEGORY_UI_INTERACTIONS, ACTION_SELECTION_MODE_OFF);
        isInSelectionMode = false;
    }
}
 
Example #16
Source File: ListHeadingCardItemView.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
public void build(@NonNull ListHeadingCard card) {
    super.build(card);

    Version1TextView leftText = (Version1TextView) findViewById(R.id.left_text);
    Version1TextView rightText = (Version1TextView) findViewById(R.id.right_text);

    if (card.getLeftText() == null) {
        leftText.setVisibility(GONE);
    } else {
        leftText.setText(card.getLeftText());
        leftText.setVisibility(VISIBLE);
    }

    if (card.getRightText() == null) {
        rightText.setVisibility(GONE);
    } else {
        rightText.setText(card.getRightText());
        rightText.setVisibility(VISIBLE);
    }

    CardView cardView = (CardView) findViewById(R.id.cardView);
    if (cardView != null) {
        cardView.setCardBackgroundColor(getResources().getColor(R.color.overlay_white_with_20));
    }
}
 
Example #17
Source File: AlertDialogsHelper.java    From leafpicrevived with GNU General Public License v3.0 6 votes vote down vote up
public static AlertDialog getProgressDialog(final ThemedActivity activity, String title, String message) {
    AlertDialog.Builder progressDialog = new AlertDialog.Builder(activity, activity.getDialogStyle());
    View dialogLayout = activity.getLayoutInflater().inflate(com.alienpants.leafpicrevived.R.layout.dialog_progress, null);
    TextView dialogTitle = dialogLayout.findViewById(R.id.progress_dialog_title);
    TextView dialogMessage = dialogLayout.findViewById(R.id.progress_dialog_text);

    dialogTitle.setBackgroundColor(activity.getPrimaryColor());
    ((CardView) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.progress_dialog_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
    ((ProgressBar) dialogLayout.findViewById(com.alienpants.leafpicrevived.R.id.progress_dialog_loading)).getIndeterminateDrawable().setColorFilter(activity.getPrimaryColor(), android.graphics
            .PorterDuff.Mode.SRC_ATOP);

    dialogTitle.setText(title);
    dialogMessage.setText(message);
    dialogMessage.setTextColor(activity.getTextColor());

    progressDialog.setCancelable(false);
    progressDialog.setView(dialogLayout);
    return progressDialog.create();
}
 
Example #18
Source File: NoteViewHolder.java    From science-journal with Apache License 2.0 6 votes vote down vote up
public NoteViewHolder(View v) {
  super(v);
  durationText = (TextView) v.findViewById(R.id.time_text);
  menuButton = (ImageButton) v.findViewById(R.id.note_menu_button);
  text = (TextView) v.findViewById(R.id.note_text);
  image = (ImageView) v.findViewById(R.id.note_image);
  captionIcon = (ImageView) v.findViewById(R.id.edit_icon);
  captionView = itemView.findViewById(R.id.caption_section);
  captionTextView = (TextView) itemView.findViewById(R.id.caption);
  valuesList = (ViewGroup) itemView.findViewById(R.id.snapshot_values_list);
  relativeTimeView = (RelativeTimeTextView) itemView.findViewById(R.id.relative_time_text);
  CardView cardView = v.findViewById(R.id.card_view);
  cardView.setUseCompatPadding(true);
  cardView.setCardElevation(0);
  cardView.setBackground(
      cardView.getResources().getDrawable(R.drawable.card_view_with_hairline_border));
}
 
Example #19
Source File: MoDialogView.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 显示图像和文本
 */
public void showImageText(Bitmap bitmap, String text) {
    removeAllViews();
    LayoutInflater.from(getContext()).inflate(R.layout.mo_dialog_image_text, this, true);
    CardView cardView = findViewById(R.id.cv_content);
    cardView.setOnClickListener(null);
    ImageView imageView = findViewById(R.id.image_view);
    TextView tvCanCopy = findViewById(R.id.tv_can_copy);
    int imageWidth = Math.min(cardView.getWidth(), cardView.getHeight());
    imageView.setMaxWidth(imageWidth - 20);
    imageView.setMaxHeight(imageWidth - 20);
    imageView.setImageBitmap(bitmap);
    tvCanCopy.setText(text);
}
 
Example #20
Source File: ExperimentDetailsFragment.java    From science-journal with Apache License 2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  View view;
  LayoutInflater inflater = LayoutInflater.from(parent.getContext());
  if (viewType == VIEW_TYPE_EXPERIMENT_TEXT_LABEL
      || viewType == VIEW_TYPE_EXPERIMENT_PICTURE_LABEL
      || viewType == VIEW_TYPE_EXPERIMENT_TRIGGER_LABEL
      || viewType == VIEW_TYPE_SNAPSHOT_LABEL
      || viewType == VIEW_TYPE_SKETCH) {
    view = inflater.inflate(R.layout.exp_card_pinned_note, parent, false);
    return new NoteViewHolder(view);
  } else if (viewType == VIEW_TYPE_RECORDING) {
    view = inflater.inflate(R.layout.exp_card_recording, parent, false);
    return new RecordingViewHolder(view);
  } else if (viewType == VIEW_TYPE_EXPERIMENT_ARCHIVED) {
    view = inflater.inflate(R.layout.metadata_archived, parent, false);
  } else if (viewType == VIEW_TYPE_RUN_CARD) {
    view = inflater.inflate(R.layout.exp_card_run, parent, false);
  } else {
    // TODO(b/117987511): display a card that explains why we can't show this data
    view = inflater.inflate(R.layout.exp_card_empty, parent, false);
  }
  CardView cardView = view.findViewById(R.id.card_view);
  if (cardView != null) {
    cardView.setUseCompatPadding(true);
    cardView.setCardElevation(0);
    cardView.setBackground(
        cardView.getResources().getDrawable(R.drawable.card_view_with_hairline_border));
  }
  return new DetailsViewHolder(view, viewType);
}
 
Example #21
Source File: VODAdapter.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 5 votes vote down vote up
public VODViewHolder(View v) {
	super(v);
	vCard = (CardView) v.findViewById(R.id.card_view_vod_stream);
	vPreviewImage = (ImageView) v.findViewById(R.id.image_stream_preview);
	vDisplayName = (TextView) v.findViewById(R.id.displayName);
	vTitle = (TextView) v.findViewById(R.id.stream_title);
	vGame = (TextView) v.findViewById(R.id.stream_game_and_viewers);
	vTimeStamp = (TextView) v.findViewById(R.id.timestamp);
	vProgressBar = (SeekBar) v.findViewById(R.id.progressBar);
	sharedPadding = v.findViewById(R.id.shared_padding);
}
 
Example #22
Source File: CaptionBackgroundPainter.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
public void addColorBackgroundToCaption(CardView captionView, String captionColor) {
  if (captionColor != null && !captionColor.isEmpty()) {
    try {
      captionView.setCardBackgroundColor(Color.parseColor(captionColor));
    } catch (IllegalArgumentException e) {
      setDefaultBackgroundColor(captionView);
    }
  } else {
    setDefaultBackgroundColor(captionView);
  }
}
 
Example #23
Source File: HorizontalAlbumAdapter.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void setColors(int color, ViewHolder holder) {
    if (holder.itemView != null) {
        CardView card = (CardView) holder.itemView;
        card.setCardBackgroundColor(color);
        if (holder.title != null) {
                holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
        if (holder.text != null) {
                holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
    }
}
 
Example #24
Source File: StreamsAdapter.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 5 votes vote down vote up
public StreamViewHolder(View v) {
	super(v);
	vCard = (CardView) v.findViewById(R.id.cardView_online_streams);
	vPreviewImage = (ImageView) v.findViewById(R.id.image_stream_preview);
	vDisplayName = (TextView) v.findViewById(R.id.displayName);
	vTitle = (TextView) v.findViewById(R.id.stream_title);
	vGame = (TextView) v.findViewById(R.id.stream_game_and_viewers);
	sharedPadding = v.findViewById(R.id.shared_padding);
	//vOnlineSince = (TextView) v.findViewById(R.id.stream_online_since);
}
 
Example #25
Source File: AdvanceDrawerLayout.java    From Drawer-Behavior with MIT License 5 votes vote down vote up
@Override
public void addView(View child) {
    if (child instanceof NavigationView) {
        super.addView(child);
    } else {
        CardView cardView = new CardView(getContext());
        cardView.setRadius(0);
        cardView.addView(child);
        cardView.setCardElevation(0);
        if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            cardView.setContentPadding(-6, -9, -6, -9);
        }
        frameLayout.addView(cardView);
    }
}
 
Example #26
Source File: SpinnerPopupWindow.java    From FloatingLabelSpinner with Apache License 2.0 5 votes vote down vote up
public void setAdapter(FloatingLabelSpinner spinner, HintAdapter hintAdapter, short margin, AdapterView.OnItemSelectedListener listener) {
    this.spinner = spinner;
    View contentView = LayoutInflater.from(spinner.getContext()).inflate(R.layout.floating_label_spinner_popup_window, null, false);
    ListView listView = contentView.findViewById(R.id.list_view);
    CardView cardView = contentView.findViewById(R.id.card_view);
    dropDownViewAdapter = new DropDownViewAdapter(hintAdapter);
    listView.setAdapter(dropDownViewAdapter);

    ((FrameLayout.LayoutParams) cardView.getLayoutParams()).setMargins(margin, margin, margin, margin);
    setContentView(contentView);
    this.listener = listener;
    listView.setOnItemClickListener(this);
}
 
Example #27
Source File: DNSRelaysAdapter.java    From InviZible with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onFocusChange(View view, boolean newValue) {
    if (newValue) {
        ((CardView) view).setCardBackgroundColor(context.getResources().getColor(R.color.colorSecond));
    } else {
        ((CardView) view).setCardBackgroundColor(context.getResources().getColor(R.color.colorFirst));
    }
}
 
Example #28
Source File: HorizontalAlbumAdapter.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void setColors(int color, ViewHolder holder) {
    if (holder.itemView != null) {
        CardView card=(CardView)holder.itemView;
        card.setCardBackgroundColor(color);
        if (holder.title != null) {
                holder.title.setTextColor(MaterialValueHelper.getPrimaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
        if (holder.text != null) {
                holder.text.setTextColor(MaterialValueHelper.getSecondaryTextColor(activity, ColorUtil.isColorLight(color)));
        }
    }
}
 
Example #29
Source File: MapLayerListFragment.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onStartDragAnimation(View dragView) {
    CardView dragCard = dragView.findViewById(R.id.card);
    ObjectAnimator anim = ObjectAnimator.ofFloat(dragCard, "CardElevation", dragCard.getCardElevation(), 40); //NON-NLS
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(ANIMATION_DURATION);
    anim.start();
}
 
Example #30
Source File: DiagnosticsAdapter.java    From DNSHero with GNU General Public License v3.0 5 votes vote down vote up
ViewHolder(ViewGroup parent) {
    super(inflater.inflate(R.layout.card_diagnostic, parent, false));

    card = (CardView) itemView;
    title = itemView.findViewById(R.id.diagnosticCard_title);
    description = itemView.findViewById(R.id.diagnosticCard_description);
    toggle = itemView.findViewById(R.id.diagnosticCard_toggle);
    recommendation = itemView.findViewById(R.id.diagnosticCard_recommendation);
    recommendationImage = (ImageView) recommendation.getChildAt(0);
    recommendationText = (TextView) recommendation.getChildAt(1);
}