use of com.google.android.material.textview.MaterialTextView in project Android by CatimaLoyalty.
the class UCropWrapper method onPostCreate.
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
boolean darkMode = Utils.isDarkModeEnabled(this);
// setup status bar to look like the rest of the app
if (Build.VERSION.SDK_INT >= 23) {
getWindow().getDecorView().setSystemUiVisibility(darkMode ? 0 : View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
} else {
// icons are always white back then
if (!darkMode) {
getWindow().setStatusBarColor(ColorUtils.compositeColors(Color.argb(127, 0, 0, 0), getWindow().getStatusBarColor()));
}
}
// find and check views that we wish to color modify
// for when we update ucrop or switch to another cropper
View check = findViewById(com.yalantis.ucrop.R.id.wrapper_controls);
if (check instanceof FrameLayout) {
FrameLayout controls = (FrameLayout) check;
check = findViewById(com.yalantis.ucrop.R.id.wrapper_states);
if (check instanceof LinearLayout) {
LinearLayout states = (LinearLayout) check;
for (int i = 0; i < controls.getChildCount(); i++) {
check = controls.getChildAt(i);
if (check instanceof AppCompatImageView) {
AppCompatImageView controlsBackgroundImage = (AppCompatImageView) check;
// everything gathered and are as expected, now perform color patching
Utils.patchColors(this);
int colorSurface = MaterialColors.getColor(this, R.attr.colorSurface, ContextCompat.getColor(this, R.color.md_theme_light_surface));
int colorOnSurface = MaterialColors.getColor(this, R.attr.colorOnSurface, ContextCompat.getColor(this, R.color.md_theme_light_onSurface));
Drawable controlsBackgroundImageDrawable = controlsBackgroundImage.getBackground();
controlsBackgroundImageDrawable.mutate();
controlsBackgroundImageDrawable.setTint(darkMode ? colorOnSurface : colorSurface);
controlsBackgroundImage.setBackgroundDrawable(controlsBackgroundImageDrawable);
states.setBackgroundColor(darkMode ? colorSurface : colorOnSurface);
break;
}
}
}
}
// change toolbar font
check = findViewById(com.yalantis.ucrop.R.id.toolbar_title);
if (check instanceof MaterialTextView) {
MaterialTextView toolbarTextview = (MaterialTextView) check;
Intent intent = getIntent();
int style = intent.getIntExtra(UCROP_TOOLBAR_TYPEFACE_STYLE, -1);
if (style != -1) {
toolbarTextview.setTypeface(Typeface.defaultFromStyle(style));
}
}
}
use of com.google.android.material.textview.MaterialTextView in project edx-app-android by openedx.
the class CourseOutlineAdapter method getCardView.
public View getCardView(View view) {
final MaterialTextView courseTextName = view.findViewById(R.id.course_detail_name);
final MaterialTextView courseTextDetails = view.findViewById(R.id.course_detail_extras);
final AppCompatImageView headerImageView = view.findViewById(R.id.header_image_view);
final View upgradeBtn = view.findViewById(R.id.layout_upgrade_btn);
final MaterialButton upgradeBtnText = upgradeBtn.findViewById(R.id.btn_upgrade);
((ShimmerFrameLayout) upgradeBtn).hideShimmer();
upgradeBtn.setVisibility(courseData.getMode().equalsIgnoreCase(EnrollmentMode.AUDIT.toString()) ? View.VISIBLE : View.GONE);
upgradeBtnText.setOnClickListener(view1 -> CourseModalDialogFragment.newInstance(environment.getConfig().getPlatformName(), courseData.getCourseId(), courseData.getCourse().getName(), courseData.getCourse().getPrice(), courseData.getCourse().isSelfPaced()).show(((AppCompatActivity) context).getSupportFragmentManager(), CourseModalDialogFragment.TAG));
upgradeBtnText.setText(R.string.value_prop_course_card_message);
// Full course name should appear on the course's dashboard screen.
courseTextName.setEllipsize(null);
courseTextName.setSingleLine(false);
final String headerImageUrl = courseData.getCourse().getCourse_image(environment.getConfig().getApiHostURL());
Glide.with(context).load(headerImageUrl).placeholder(R.drawable.placeholder_course_card_image).transform(new TopAnchorFillWidthTransformation()).into(headerImageView);
courseTextName.setText(courseData.getCourse().getName());
courseTextDetails.setText(CourseCardUtils.getFormattedDate(context, courseData));
return view;
}
use of com.google.android.material.textview.MaterialTextView in project a-medic-log by rh-id.
the class MedicineItemSV method createView.
@Override
protected View createView(Activity activity, ViewGroup container) {
View rootLayout = activity.getLayoutInflater().inflate(R.layout.item_medicine, container, false);
rootLayout.setOnClickListener(this);
TextView nameText = rootLayout.findViewById(R.id.text_name);
TextView descriptionText = rootLayout.findViewById(R.id.text_description);
TextView lastIntakeText = rootLayout.findViewById(R.id.text_last_intake);
Button editButton = rootLayout.findViewById(R.id.button_edit);
editButton.setOnClickListener(this);
Button deleteButton = rootLayout.findViewById(R.id.button_delete);
deleteButton.setOnClickListener(this);
Button moreAction = rootLayout.findViewById(R.id.button_more_action);
moreAction.setOnClickListener(this);
GridLayout containerReminder = rootLayout.findViewById(R.id.container_reminder);
mRxDisposer.add("createView_onMedicineStateChanged", mMedicineStateSubject.getSubject().debounce(16, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(medicineState -> {
nameText.setText(medicineState.getMedicineName());
descriptionText.setText(medicineState.getMedicineDescription());
if (medicineState.getMedicineId() != null) {
moreAction.setVisibility(View.VISIBLE);
} else {
moreAction.setVisibility(View.GONE);
}
queryLastMedicineIntake(medicineState.getMedicineId());
containerReminder.removeAllViews();
ArrayList<MedicineReminder> medicineReminders = medicineState.getMedicineReminderList();
if (medicineReminders != null && !medicineReminders.isEmpty()) {
containerReminder.setVisibility(View.VISIBLE);
for (MedicineReminder medicineReminder : medicineReminders) {
MaterialTextView materialTextView = new MaterialTextView(activity);
materialTextView.setText(mTimeFormat.format(medicineReminder.startDateTime));
GridLayout.LayoutParams params = new GridLayout.LayoutParams();
params.width = GridLayout.LayoutParams.WRAP_CONTENT;
params.height = GridLayout.LayoutParams.WRAP_CONTENT;
params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1.0f);
materialTextView.setLayoutParams(params);
materialTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
int tintColor = activity.getResources().getColor(R.color.daynight_black_white);
Drawable icon;
if (medicineReminder.reminderEnabled) {
icon = AppCompatResources.getDrawable(activity, R.drawable.ic_timer_black);
} else {
icon = AppCompatResources.getDrawable(activity, R.drawable.ic_timer_off_black);
}
icon = DrawableCompat.wrap(icon);
DrawableCompat.setTint(icon, tintColor);
materialTextView.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
containerReminder.addView(materialTextView);
}
} else {
containerReminder.setVisibility(View.GONE);
}
}));
mRxDisposer.add("createView_onLastMedicineIntakeChanged", mLastMedicineIntakeSubject.getSubject().debounce(100, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(medicineIntakeOpt -> {
if (medicineIntakeOpt.isPresent()) {
Date takenDateTime = medicineIntakeOpt.get().takenDateTime;
lastIntakeText.setText(mDateTimeFormat.format(takenDateTime));
lastIntakeText.setVisibility(View.VISIBLE);
} else {
lastIntakeText.setText(null);
lastIntakeText.setVisibility(View.GONE);
}
}));
mRxDisposer.add("createView_onMedicineIntakeAdded", mMedicineIntakeChangeNotifier.getAddedMedicineIntake().observeOn(Schedulers.from(mExecutorService)).subscribe(medicineIntake -> {
if (medicineIntake.medicineId != null && medicineIntake.medicineId.equals(mMedicineStateSubject.getValue().getMedicineId())) {
queryLastMedicineIntake(medicineIntake.medicineId);
}
}));
mRxDisposer.add("createView_onMedicineIntakeUpdated", mMedicineIntakeChangeNotifier.getUpdatedMedicineIntake().observeOn(Schedulers.from(mExecutorService)).subscribe(updateMedicineIntakeEvent -> {
MedicineIntake medicineIntake = updateMedicineIntakeEvent.getAfter();
if (medicineIntake.medicineId != null && medicineIntake.medicineId.equals(mMedicineStateSubject.getValue().getMedicineId())) {
queryLastMedicineIntake(medicineIntake.medicineId);
}
}));
mRxDisposer.add("createView_onMedicineIntakeDeleted", mMedicineIntakeChangeNotifier.getDeletedMedicineIntake().observeOn(Schedulers.from(mExecutorService)).subscribe(medicineIntake -> {
if (medicineIntake.medicineId != null && medicineIntake.medicineId.equals(mMedicineStateSubject.getValue().getMedicineId())) {
queryLastMedicineIntake(medicineIntake.medicineId);
}
}));
return rootLayout;
}
use of com.google.android.material.textview.MaterialTextView in project edx-app-android by edx.
the class CourseOutlineAdapter method getCardView.
public View getCardView(View view) {
final MaterialTextView courseTextName = view.findViewById(R.id.course_detail_name);
final MaterialTextView courseTextDetails = view.findViewById(R.id.course_detail_extras);
final AppCompatImageView headerImageView = view.findViewById(R.id.header_image_view);
final View upgradeBtn = view.findViewById(R.id.layout_upgrade_btn);
final MaterialButton upgradeBtnText = upgradeBtn.findViewById(R.id.btn_upgrade);
((ShimmerFrameLayout) upgradeBtn).hideShimmer();
upgradeBtn.setVisibility(courseData.getMode().equalsIgnoreCase(EnrollmentMode.AUDIT.toString()) ? View.VISIBLE : View.GONE);
upgradeBtnText.setOnClickListener(view1 -> CourseModalDialogFragment.newInstance(environment.getConfig().getPlatformName(), courseData.getCourseId(), courseData.getCourse().getName(), courseData.getCourse().getPrice(), courseData.getCourse().isSelfPaced()).show(((AppCompatActivity) context).getSupportFragmentManager(), CourseModalDialogFragment.TAG));
upgradeBtnText.setText(R.string.value_prop_course_card_message);
// Full course name should appear on the course's dashboard screen.
courseTextName.setEllipsize(null);
courseTextName.setSingleLine(false);
final String headerImageUrl = courseData.getCourse().getCourse_image(environment.getConfig().getApiHostURL());
Glide.with(context).load(headerImageUrl).placeholder(R.drawable.placeholder_course_card_image).transform(new TopAnchorFillWidthTransformation()).into(headerImageView);
courseTextName.setText(courseData.getCourse().getName());
courseTextDetails.setText(CourseCardUtils.getFormattedDate(context, courseData));
return view;
}
Aggregations