Search in sources :

Example 1 with TextView

use of com.rey.material.widget.TextView in project material by rey5137.

the class SimpleDialog method initMessageView.

private void initMessageView() {
    mMessage = new TextView(getContext());
    mMessage.setTextAppearance(getContext(), mMessageTextAppearanceId);
    mMessage.setTextColor(mMessageTextColor);
    mMessage.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
}
Also used : TextView(com.rey.material.widget.TextView)

Example 2 with TextView

use of com.rey.material.widget.TextView in project material by rey5137.

the class RecurringPickerDialog method onCreate.

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
protected void onCreate() {
    View v = LayoutInflater.from(getContext()).inflate(R.layout.dialog_recurring, null);
    setContentView(v);
    FrameLayout fl_mode = (FrameLayout) v.findViewById(R.id.rd_fl_mode);
    final ScrollView sv_repeat = (ScrollView) v.findViewById(R.id.rd_sv_repeat);
    final LinearLayout ll_repeat = (LinearLayout) v.findViewById(R.id.rd_ll_repeat);
    mModeSpinner = (Spinner) fl_mode.findViewById(R.id.rd_spn_mode);
    mEndSpinner = (Spinner) v.findViewById(R.id.rd_spn_end);
    mPeriodEditText = (EditText) v.findViewById(R.id.rd_et_period);
    mPeriodUnitTextView = (TextView) v.findViewById(R.id.rd_tv_period_unit);
    mSameDayRadioButton = (RadioButton) v.findViewById(R.id.rd_month_rb_same);
    mSameWeekdayRadioButton = (RadioButton) v.findViewById(R.id.rd_month_rb_week);
    mEndNumEditText = (EditText) v.findViewById(R.id.rd_et_end_num);
    mEndNumUnitTextView = (TextView) v.findViewById(R.id.rd_tv_end_num_unit);
    mEndDateButton = (Button) v.findViewById(R.id.rd_bt_end_date);
    mWeekView = (WeekView) v.findViewById(R.id.rd_wv_week);
    sv_repeat.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            showDivider(ll_repeat.getMeasuredHeight() > sv_repeat.getMeasuredHeight());
        }
    });
    mHeaderBackground = new HeaderDrawable(getContext());
    ViewCompat.setPaddingRelative(fl_mode, mContentPadding, 0, mContentPadding, 0);
    ViewUtil.setBackground(fl_mode, mHeaderBackground);
    ViewCompat.setPaddingRelative(ll_repeat, mContentPadding, mActionOuterPadding, mContentPadding, mActionPadding);
    mModeAdapter = new ModeAdapter();
    mModeSpinner.setAdapter(mModeAdapter);
    mModeSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {

        @Override
        public void onItemSelected(Spinner parent, View view, int position, long id) {
            onModeSelected(position);
        }
    });
    mEndAdapter = new EndAdapter();
    mEndSpinner.setAdapter(mEndAdapter);
    mEndSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {

        @Override
        public void onItemSelected(Spinner parent, View view, int position, long id) {
            onEndSelected(position);
        }
    });
    mPeriodEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            onPeriodChanged();
        }
    });
    mPeriodEditText.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
                String text = mPeriodEditText.getText().toString();
                if (TextUtils.isEmpty(text))
                    mPeriodEditText.setText(String.valueOf(mRecurring.getPeriod()));
            }
            return false;
        }
    });
    CompoundButton.OnCheckedChangeListener mCheckChangeListener = new android.widget.CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(android.widget.CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                if (buttonView == mSameDayRadioButton)
                    mSameWeekdayRadioButton.setChecked(false);
                else
                    mSameDayRadioButton.setChecked(false);
                onMonthSettingChanged();
            }
        }
    };
    mSameDayRadioButton.setOnCheckedChangeListener(mCheckChangeListener);
    mSameWeekdayRadioButton.setOnCheckedChangeListener(mCheckChangeListener);
    mEndNumEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            onEventNumberChanged();
        }
    });
    mEndNumEditText.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
                String text = mEndNumEditText.getText().toString();
                if (TextUtils.isEmpty(text))
                    mEndNumEditText.setText(String.valueOf(mRecurring.getEventNumber()));
            }
            return false;
        }
    });
    View.OnClickListener mDateClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final DatePickerDialog dialog = new DatePickerDialog(getContext(), mDatePickerDialogStyleId);
            long minTime = System.currentTimeMillis();
            Calendar cal = dialog.getCalendar();
            cal.setTimeInMillis(minTime);
            cal.add(Calendar.YEAR, 100);
            long maxTime = cal.getTimeInMillis();
            dialog.dateRange(minTime, maxTime).date((long) mEndDateButton.getTag()).positiveAction(mPositiveAction.getText()).positiveActionClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    onEndDateChanged(dialog.getDate());
                    dialog.dismiss();
                }
            }).negativeAction(mNegativeAction.getText()).negativeActionClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            }).show();
        }
    };
    mEndDateButton.setOnClickListener(mDateClickListener);
    mWeekView.setOnDaySelectionChangedListener(this);
}
Also used : Spinner(com.rey.material.widget.Spinner) KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) ViewTreeObserver(android.view.ViewTreeObserver) Calendar(java.util.Calendar) View(android.view.View) TextView(com.rey.material.widget.TextView) ScrollView(android.widget.ScrollView) Paint(android.graphics.Paint) ScrollView(android.widget.ScrollView) FrameLayout(android.widget.FrameLayout) LinearLayout(android.widget.LinearLayout) CompoundButton(com.rey.material.widget.CompoundButton) TargetApi(android.annotation.TargetApi)

Example 3 with TextView

use of com.rey.material.widget.TextView in project material by rey5137.

the class Dialog method init.

private void init(Context context, int style) {
    mContentPadding = ThemeUtil.dpToPx(context, 24);
    mActionMinWidth = ThemeUtil.dpToPx(context, 64);
    mActionHeight = ThemeUtil.dpToPx(context, 36);
    mActionOuterHeight = ThemeUtil.dpToPx(context, 48);
    mActionPadding = ThemeUtil.dpToPx(context, 8);
    mActionOuterPadding = ThemeUtil.dpToPx(context, 16);
    mDialogHorizontalPadding = ThemeUtil.dpToPx(context, 40);
    mDialogVerticalPadding = ThemeUtil.dpToPx(context, 24);
    mCardView = new DialogCardView(context);
    mContainer = new ContainerFrameLayout(context);
    mTitle = new TextView(context);
    mPositiveAction = new Button(context);
    mNegativeAction = new Button(context);
    mNeutralAction = new Button(context);
    mCardView.setPreventCornerOverlap(false);
    mCardView.setUseCompatPadding(true);
    mTitle.setId(TITLE);
    mTitle.setGravity(Gravity.START);
    mTitle.setPadding(mContentPadding, mContentPadding, mContentPadding, mContentPadding - mActionPadding);
    mPositiveAction.setId(ACTION_POSITIVE);
    mPositiveAction.setPadding(mActionPadding, 0, mActionPadding, 0);
    mPositiveAction.setBackgroundResource(0);
    mNegativeAction.setId(ACTION_NEGATIVE);
    mNegativeAction.setPadding(mActionPadding, 0, mActionPadding, 0);
    mNegativeAction.setBackgroundResource(0);
    mNeutralAction.setId(ACTION_NEUTRAL);
    mNeutralAction.setPadding(mActionPadding, 0, mActionPadding, 0);
    mNeutralAction.setBackgroundResource(0);
    mContainer.addView(mCardView);
    mCardView.addView(mTitle);
    mCardView.addView(mPositiveAction);
    mCardView.addView(mNegativeAction);
    mCardView.addView(mNeutralAction);
    backgroundColor(ThemeUtil.windowBackground(context, 0xFFFFFFFF));
    elevation(ThemeUtil.dpToPx(context, 4));
    cornerRadius(ThemeUtil.dpToPx(context, 2));
    dimAmount(0.5f);
    layoutDirection(View.LAYOUT_DIRECTION_LOCALE);
    titleTextAppearance(R.style.TextAppearance_AppCompat_Title);
    actionTextAppearance(R.style.TextAppearance_AppCompat_Button);
    dividerColor(0x1E000000);
    dividerHeight(ThemeUtil.dpToPx(context, 1));
    cancelable(true);
    canceledOnTouchOutside(true);
    clearContent();
    onCreate();
    applyStyle(style);
    super.setContentView(mContainer);
}
Also used : Button(com.rey.material.widget.Button) TextView(com.rey.material.widget.TextView)

Aggregations

TextView (com.rey.material.widget.TextView)3 TargetApi (android.annotation.TargetApi)1 Paint (android.graphics.Paint)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 KeyEvent (android.view.KeyEvent)1 View (android.view.View)1 ViewTreeObserver (android.view.ViewTreeObserver)1 FrameLayout (android.widget.FrameLayout)1 LinearLayout (android.widget.LinearLayout)1 ScrollView (android.widget.ScrollView)1 Button (com.rey.material.widget.Button)1 CompoundButton (com.rey.material.widget.CompoundButton)1 Spinner (com.rey.material.widget.Spinner)1 Calendar (java.util.Calendar)1