Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  ViewUtil.java

  Sprache: JAVA
 

package ch.threema.app.utils;

import android.os.Build;
import android.text.Spannable;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;

import androidx.annotation.NonNull;

import java.lang.reflect.Method;

public class ViewUtil {
    /**
     * show the view and return true if exist
     */

    public static boolean show(View view) {
        return show(view, true);
    }

    /**
     * show or hide the view and return true if exist
     */

    public static boolean show(View view, boolean show) {
        if (view == null) {
            return false;
        }

        view.setVisibility(show ? View.VISIBLE : View.GONE);
        return true;
    }

    public static boolean show(MenuItem menuItem, boolean show) {
        if (menuItem == null) {
            return false;
        }

        menuItem.setVisible(show);
        return true;
    }

    public static boolean showAndSet(ImageView view, int imageResourceId) {
        if (!show(view)) {
            return false;
        }
        view.setImageResource(imageResourceId);
        return true;
    }

    /**
     * show a text view and set the text, return true if the view exist
     */

    public static boolean showAndSet(TextView view, String text) {
        if (!show(view)) {
            return false;
        }

        view.setText(text);
        return true;
    }

    public static boolean showAndSet(TextView view, Spannable text) {
        if (!show(view)) {
            return false;
        }

        view.setText(text);
        return true;
    }

    /**
     * show a checkbox view and set the check state, return true if the view exist
     */

    public static boolean showAndSet(CheckBox view, boolean checked) {
        if (!show(view)) {
            return false;
        }

        view.setChecked(checked);
        return true;
    }

    /**
     * Set touchModal flag of PopupWindow which is hidden on API<29
     *
     * @param popupWindow PopupWindow
     * @param touchModal  whether to enable or disable the flag
     */

    public static void setTouchModal(@NonNull PopupWindow popupWindow, boolean touchModal) {
        if (Build.VERSION.SDK_INT >= 29) {
            popupWindow.setTouchModal(touchModal);
        } else {
            Method method;
            try {
                method = PopupWindow.class.getDeclaredMethod("setTouchModal"boolean.class);
                method.setAccessible(true);
                method.invoke(popupWindow, touchModal);
            } catch (Exception e) {
                // ignore
            }
        }
    }
}

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

¤ Dauer der Verarbeitung: 0.18 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge