Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Threema/app/src/main/java/ch/threema/app/ui/     Datei vom 25.3.2026 mit Größe 2 kB image not shown  

Quelle  SingleToast.java

  Sprache: JAVA
 

package ch.threema.app.ui;

import android.annotation.SuppressLint;
import android.view.Gravity;
import android.widget.Toast;

import androidx.annotation.UiThread;
import ch.threema.app.ThreemaApplication;

public class SingleToast {
    private Toast toast = null;

    private static SingleToast sInstance = null;

    public static synchronized SingleToast getInstance() {
        if (sInstance == null) {
            sInstance = new SingleToast();
        }
        return sInstance;
    }

    private SingleToast() {
    }

    public SingleToast text(String text, int length) {
        return this.text(text, length, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    }

    @SuppressLint("ShowToast")
    synchronized public SingleToast text(String text, int length, int gravity, int x, int y) {
        if (this.toast == null) {
            this.toast = Toast.makeText(ThreemaApplication.getAppContext(), text, length);

            if (gravity != 0 || x != 0 || y != 0) {
                this.toast.setGravity(gravity, x, y);
            }

        } else if (this.toast.getGravity() != gravity
            || this.toast.getXOffset() != x
            || this.toast.getYOffset() != y) {
            //close toast to reset gravity
            this.toast.cancel();
            this.toast = null;
            this.text(text, length, gravity, x, y);
            return this;
        } else {
            this.toast.setText(text);
        }

        this.toast.show();
        return this;
    }

    public SingleToast close() {
        if (this.toast != null) {
            this.toast.cancel();
            this.toast = null;
        }
        return this;
    }

    @UiThread
    public void showShortText(String text) {
        showText(text, Toast.LENGTH_SHORT);
    }

    @UiThread
    public void showLongText(String text) {
        showText(text, Toast.LENGTH_LONG);
    }

    @UiThread
    private void showText(String text, int length) {
        text(text, length);
    }

    @UiThread
    public void showBottom(String text, int length) {
        text(text, length, 0, 0, 0);
    }
}

Messung V0.5 in Prozent
C=95 H=96 G=95

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.