All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.solovyev.android.samples.menu.SamplesStaticMenu Maven / Gradle / Ivy

There is a newer version: 1.1.18
Show newest version
package org.solovyev.android.samples.menu;

import android.app.Activity;
import android.content.Context;
import android.view.MenuItem;
import android.widget.Toast;
import org.jetbrains.annotations.NotNull;
import org.solovyev.android.AndroidUtils;
import org.solovyev.android.menu.LabeledMenuItem;
import org.solovyev.android.samples.R;

/**
 * User: serso
 * Date: 8/10/12
 * Time: 1:18 PM
 */

/**
 * Context independent menu
 */
public enum SamplesStaticMenu implements LabeledMenuItem  {
    
    show_text(R.string.show_text) {
        @Override
        public void onClick(@NotNull MenuItem data, @NotNull Context context) {
            Toast.makeText(context, context.getString(R.string.show_text_text), Toast.LENGTH_SHORT).show();
        }
    },

    restart_activity(R.string.restart_activity) {
        @Override
        public void onClick(@NotNull MenuItem data, @NotNull Context context) {
            AndroidUtils.restartActivity((Activity) context);
        }
    };

    private int captionResId;

    private SamplesStaticMenu(int captionResId) {
        this.captionResId = captionResId;
    }


    @NotNull
    @Override
    public String getCaption(@NotNull Context context) {
        return context.getString(captionResId);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy