Virtual Trading v2.0.95版本的 MD5 值为:ef0f95d706f7364286da0edbbd29a27d

以下内容为反编译后的 DevYbPopupMenu.java 源代码,内容仅作参考


package com.devyb.devybpopupmenu;

import android.app.Activity;
import android.content.Context;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.MenuItem;
import android.widget.PopupMenu;
import com.google.appinventor.components.annotations.DesignerComponent;
import com.google.appinventor.components.annotations.DesignerProperty;
import com.google.appinventor.components.annotations.SimpleEvent;
import com.google.appinventor.components.annotations.SimpleFunction;
import com.google.appinventor.components.annotations.SimpleObject;
import com.google.appinventor.components.annotations.SimpleProperty;
import com.google.appinventor.components.common.ComponentCategory;
import com.google.appinventor.components.runtime.AndroidNonvisibleComponent;
import com.google.appinventor.components.runtime.AndroidViewComponent;
import com.google.appinventor.components.runtime.ComponentContainer;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.util.YailList;

@DesignerComponent(category = ComponentCategory.EXTENSION, description = "PopupMenu developed by DevYB.\nThis extension allows you to show a simple popup menu.\nNOTE: The background color of the menu can not be changed.", iconName = "https://res.cloudinary.com/dujfnjfcz/image/upload/v1592825515/IconEX2.png", nonVisible = true, version = 1)
@SimpleObject(external = true)
public class DevYbPopupMenu extends AndroidNonvisibleComponent {
    private Activity activity;
    private Context context;
    private int textColor;

    public DevYbPopupMenu(ComponentContainer componentContainer) {
        super(componentContainer.$form());
        this.textColor = -1;
        this.activity = componentContainer.$context();
        this.context = componentContainer.$context();
    }

    @SimpleEvent
    public void OnDismiss() {
        EventDispatcher.dispatchEvent(this, "OnDismiss", new Object[0]);
    }

    @SimpleEvent
    public void OnMenuItemClick(String str) {
        EventDispatcher.dispatchEvent(this, "OnMenuItemClick", str);
    }

    @SimpleFunction
    public void ShowPopupMenu(AndroidViewComponent androidViewComponent, YailList yailList) {
        PopupMenu popupMenu = new PopupMenu(this.context, androidViewComponent.getView());
        for (String str : yailList.toStringArray()) {
            popupMenu.getMenu().add(str);
        }
        for (int i = 0; i < popupMenu.getMenu().size(); i++) {
            MenuItem item = popupMenu.getMenu().getItem(i);
            SpannableString spannableString = new SpannableString(popupMenu.getMenu().getItem(i).getTitle().toString());
            spannableString.setSpan(new ForegroundColorSpan(this.textColor), 0, spannableString.length(), 0);
            item.setTitle(spannableString);
        }
        popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem menuItem) {
                DevYbPopupMenu.this.OnMenuItemClick(menuItem.getTitle().toString());
                return true;
            }
        });
        popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
            @Override
            public void onDismiss(PopupMenu popupMenu2) {
                DevYbPopupMenu.this.OnDismiss();
            }
        });
        popupMenu.show();
    }

    @SimpleProperty
    @DesignerProperty(defaultValue = "&HEEEEEEFF", editorType = "color")
    public void TextColor(int i) {
        this.textColor = i;
    }
}