android.widget.TextClock Java Examples

The following examples show how to use android.widget.TextClock. 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: SimpleClockDreamService.java    From androidtv-daydream with Apache License 2.0 6 votes vote down vote up
@Override
public void onDreamingStarted() {
    super.onDreamingStarted();

    SharedPreferences prefs = getSharedPreferences(getString(R.string.setting_header),
            Context.MODE_PRIVATE);
    mClock12hour = prefs.getBoolean(getString(R.string.setting_12hour), true);

    TimeZone tz = TimeZone.getTimeZone(getString(R.string.pst_time_zone));
    TextClock tc = (TextClock) findViewById(R.id.text_clock);
    TextView tv = (TextView) findViewById(R.id.clock_format);
    if (mClock12hour) {
        tc.setFormat12Hour(getString(R.string.format_12hour));
        tv.setText(getString(R.string.setting_12hour));
    } else {
        tc.setFormat12Hour(getString(R.string.format_24hour));
        tv.setText(getString(R.string.setting_24hour));
    }
    tc.setTimeZone(tz.getID());
}
 
Example #2
Source File: Drifter.java    From androidtv-daydream with Apache License 2.0 6 votes vote down vote up
public void run() {
    final View parent = (View) getParent();
    if (parent == null) return;

    // reposition in parent using setX() and setY()
    final float width = getMeasuredWidth();
    final float height = getMeasuredHeight();
    final float parentw = parent.getMeasuredWidth();
    final float parenth = parent.getMeasuredHeight();
    setX((float) Math.random() * width + (parentw/2 - width));
    setY((float) Math.random() * height + (parenth/2 - height));

    Random rand = new Random();
    // generate the random integers for r, g and b value
    int r = rand.nextInt(COLOR_MAX);
    int g = rand.nextInt(COLOR_MAX);
    int b = rand.nextInt(COLOR_MAX);
    int randomColor = Color.rgb(r, g, b);
    TextClock tc = (TextClock) findViewById(R.id.text_clock);
    tc.setTextColor(randomColor);

    postDelayed(this, DRIFT_DELAY); // let’s do this again, soon
}
 
Example #3
Source File: TimeWidgetView.java    From black-mirror with MIT License 5 votes vote down vote up
private void init(Context context) {
    this.context = context;
    inflate(context, R.layout.view_time_widget, this);
    clock = (TextClock) findViewById(R.id.text_clock);
    date = (TextView) findViewById(R.id.date);
    setVisibility(INVISIBLE);
}
 
Example #4
Source File: WatchFaceActivity.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_watch_face);

    mBackground = (ImageView) findViewById( R.id.watch_background );
    mContainer = (LinearLayout) findViewById( R.id.watch_container );
    mClock = (TextClock) findViewById( R.id.watch_time );
}
 
Example #5
Source File: FirstCardHeaderController.java    From GeometricWeather with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressLint({"SetTextI18n", "InflateParams"})
public FirstCardHeaderController(@NonNull GeoActivity activity, @NonNull Location location) {
    this.activity = activity;
    this.view = LayoutInflater.from(activity).inflate(R.layout.container_main_first_card_header, null);

    AppCompatImageView timeIcon = view.findViewById(R.id.container_main_first_card_header_timeIcon);
    TextView refreshTime = view.findViewById(R.id.container_main_first_card_header_timeText);
    TextClock localTime = view.findViewById(R.id.container_main_first_card_header_localTimeText);
    TextView alert = view.findViewById(R.id.container_main_first_card_header_alert);
    View line = view.findViewById(R.id.container_main_first_card_header_line);

    ThemeManager themeManager = ThemeManager.getInstance(activity);

    if (location.getWeather() != null) {
        this.weather = location.getWeather();

        view.setOnClickListener(v ->
                IntentHelper.startManageActivityForResult(activity, MainActivity.MANAGE_ACTIVITY));
        view.setEnabled(!MainDisplayUtils.isMultiFragmentEnabled(activity));

        if (weather.getAlertList().size() == 0) {
            timeIcon.setEnabled(false);
            timeIcon.setImageResource(R.drawable.ic_time);
        } else {
            timeIcon.setEnabled(true);
            timeIcon.setImageResource(R.drawable.ic_alert);
        }
        ImageViewCompat.setImageTintList(
                timeIcon,
                ColorStateList.valueOf(themeManager.getTextContentColor(activity))
        );
        timeIcon.setOnClickListener(this);

        refreshTime.setText(
                activity.getString(R.string.refresh_at)
                        + " "
                        + Base.getTime(activity, weather.getBase().getUpdateDate())
        );
        refreshTime.setTextColor(themeManager.getTextContentColor(activity));

        long time = System.currentTimeMillis();
        if (TimeZone.getDefault().getOffset(time) == location.getTimeZone().getOffset(time)) {
            // same time zone.
            localTime.setVisibility(View.GONE);
        } else {
            localTime.setVisibility(View.VISIBLE);
            localTime.setTimeZone(location.getTimeZone().getID());
            localTime.setTextColor(themeManager.getTextSubtitleColor(activity));
            localTime.setFormat12Hour(
                    activity.getString(R.string.date_format_widget_long) + ", h:mm aa"
            );
            localTime.setFormat24Hour(
                    activity.getString(R.string.date_format_widget_long) + ", HH:mm"
            );
        }

        if (weather.getAlertList().size() == 0) {
            alert.setVisibility(View.GONE);
            line.setVisibility(View.GONE);
        } else {
            alert.setVisibility(View.VISIBLE);
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < weather.getAlertList().size(); i ++) {
                builder.append(weather.getAlertList().get(i).getDescription())
                        .append(", ")
                        .append(
                                DateFormat.getDateTimeInstance(
                                        DateFormat.LONG,
                                        DateFormat.DEFAULT
                                ).format(weather.getAlertList().get(i).getDate())
                        );
                if (i != weather.getAlertList().size() - 1) {
                    builder.append("\n");
                }
            }
            alert.setText(builder.toString());
            alert.setTextColor(themeManager.getTextSubtitleColor(activity));

            line.setVisibility(View.VISIBLE);
            line.setBackgroundColor(themeManager.getRootColor(activity));
        }
        alert.setOnClickListener(this);
    }
}
 
Example #6
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult textClock() {
  return BaseDSL.v(TextClock.class);
}
 
Example #7
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void textClock(Anvil.Renderable r) {
  return BaseDSL.v(TextClock.class, r);
}