Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  SendButton.java

  Sprache: JAVA
 

package ch.threema.app.ui;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;

import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;

import ch.threema.app.R;

public class SendButton extends FrameLayout {
    private static final int STATE_SEND = 1;
    private static final int STATE_RECORD = 2;
    private static final int TRANSITION_DURATION_MS = 150;

    private Drawable backgroundEnabled, backgroundDisabled;
    private Context context;
    private AppCompatImageView icon;
    private TransitionDrawable transitionDrawable;
    private int currentState;
    private final Object currentStateLock = new Object();

    public SendButton(Context context) {
        this(context, null);
    }

    public SendButton(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SendButton(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {
        LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        inflater.inflate(R.layout.send_button, this);

        this.context = context;

        this.backgroundEnabled = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_circle_send, context.getTheme());
        this.backgroundDisabled = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_circle_send_disabled, context.getTheme());
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        this.icon = this.findViewById(R.id.icon);
        this.transitionDrawable = (TransitionDrawable) ContextCompat.getDrawable(getContext(), R.drawable.transition_send_button);
        this.transitionDrawable.setCrossFadeEnabled(true);
        this.icon.setImageDrawable(this.transitionDrawable);

        synchronized (currentStateLock) {
            this.transitionDrawable.resetTransition();
            currentState = STATE_SEND;
        }
    }

    public void setSend() {
        synchronized (currentStateLock) {
            if (currentState != STATE_SEND) {
                this.transitionDrawable.reverseTransition(TRANSITION_DURATION_MS);
                setContentDescription(this.context.getString(R.string.send));
                currentState = STATE_SEND;
            }
        }
    }

    public void setRecord() {
        synchronized (currentStateLock) {
            if (currentState != STATE_RECORD) {
                this.transitionDrawable.startTransition(TRANSITION_DURATION_MS);
                setContentDescription(this.context.getString(R.string.voice_message_record));
                currentState = STATE_RECORD;
            }
        }
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        setBackground(enabled ? this.backgroundEnabled : this.backgroundDisabled);
        if (!enabled) {
            setSend();
        }
    }
}

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

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik