Search in sources :

Example 86 with ImageButton

use of android.widget.ImageButton in project chefly_android by chef-ly.

the class GetCookingActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_get_cooking);
    speechListener = new ttsUtteranceListener();
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    width = metrics.widthPixels;
    height = metrics.heightPixels;
    //View Pager
    pager = (ViewPager) findViewById(R.id.viewpager);
    // Gesture Detector to repeat the current step when it detects a single tap on the screen
    final GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (hasDirections) {
                if (step < directions.size()) {
                    read(directions.get(step));
                } else {
                    read(getResources().getString(R.string.bonAppetit));
                }
            }
            return super.onSingleTapConfirmed(e);
        }

        @Override
        public void onLongPress(MotionEvent e) {
            super.onLongPress(e);
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            return super.onDoubleTap(e);
        }
    });
    // set on touch listener to ViewPager
    pager.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return gestureDetector.onTouchEvent(event);
        }
    });
    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            step = position;
            updateStepText();
            read(directions.get(position));
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    // Text view to display the current step number
    stepText = (TextView) findViewById(R.id.step);
    //Exit Button
    Button exit;
    exit = (Button) findViewById(R.id.exit);
    exit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setResult(RESULT_OK);
            finish();
        }
    });
    ImageButton btnSpeak;
    btnSpeak = (ImageButton) findViewById(R.id.btnSpeak);
    btnSpeak.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
        }
    });
    textToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {

        @Override
        public void onInit(int status) {
            if (status != TextToSpeech.ERROR) {
                textToSpeech.setLanguage(Locale.US);
                // Log.d(TAG, "Quality -> " + textToSpeech.getVoice().getQuality());
                if (directions.size() > 0) {
                    read(directions.get(0));
                }
            }
        }
    });
    // TODO replace with speech recognizer
    Button ingredBtn = (Button) findViewById(R.id.ingredientsBtn);
    ingredBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            ingredientsPopup.show(fm, "Ingredients");
            getSupportFragmentManager().executePendingTransactions();
            if (ingredientsPopup.getDialog().getWindow() != null)
                ingredientsPopup.getDialog().getWindow().setLayout((6 * width) / 7, (4 * height) / 5);
        }
    });
    // TODO replace with speech recognizer
    Button direcBtn = (Button) findViewById(R.id.directionsBtn);
    direcBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            if (directionsPopup != null) {
                directionsPopup.show(fm, "Directions");
                getSupportFragmentManager().executePendingTransactions();
                if (directionsPopup.getDialog().getWindow() != null)
                    directionsPopup.getDialog().getWindow().setLayout((6 * width) / 7, (4 * height) / 5);
            } else {
                Log.d(TAG, "Directions pop up is null.  Directions size = " + directions.size());
            }
        }
    });
    int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);
    if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.RECORD_AUDIO }, PERMISSIONS_REQUEST_RECORD_AUDIO);
    //return;
    } else {
        voiceRec.runRec();
    }
}
Also used : GestureDetector(android.view.GestureDetector) TextToSpeech(android.speech.tts.TextToSpeech) DisplayMetrics(android.util.DisplayMetrics) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ViewPager(android.support.v4.view.ViewPager) MotionEvent(android.view.MotionEvent) FragmentManager(android.support.v4.app.FragmentManager) ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button)

Example 87 with ImageButton

use of android.widget.ImageButton in project superCleanMaster by joyoyao.

the class SlidingTab method addIconTab.

private void addIconTab(final int position, int resId) {
    ImageButton tab = new ImageButton(getContext());
    tab.setImageResource(resId);
    addTab(position, tab);
}
Also used : ImageButton(android.widget.ImageButton)

Example 88 with ImageButton

use of android.widget.ImageButton in project BeyondUPnP by kevinshine.

the class PagerSlidingTabStrip method addIconTab.

private void addIconTab(final int position, int resId) {
    ImageButton tab = new ImageButton(getContext());
    tab.setImageResource(resId);
    addTab(position, tab);
}
Also used : ImageButton(android.widget.ImageButton)

Example 89 with ImageButton

use of android.widget.ImageButton in project android-actionbar by johannilsson.

the class ActionBar method inflateAction.

/**
     * Inflates a {@link View} with the given {@link Action}.
     * @param action the action to inflate
     * @return a view
     */
private View inflateAction(Action action) {
    View view = mInflater.inflate(R.layout.actionbar_item, mActionsView, false);
    ImageButton labelView = (ImageButton) view.findViewById(R.id.actionbar_item);
    labelView.setImageResource(action.getDrawable());
    view.setTag(action);
    view.setOnClickListener(this);
    return view;
}
Also used : ImageButton(android.widget.ImageButton) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 90 with ImageButton

use of android.widget.ImageButton in project Klyph by jonathangerbaud.

the class PhotoAdapter method attachHolder.

@Override
protected void attachHolder(View view) {
    ImageView authorProfileImage = (ImageView) view.findViewById(R.id.author_profile_image);
    TextView story = (TextView) view.findViewById(R.id.story);
    TextView postTime = (TextView) view.findViewById(R.id.post_time);
    TextView message = (TextView) view.findViewById(R.id.message);
    Button likeButton = (Button) view.findViewById(R.id.like_button);
    Button commentButton = (Button) view.findViewById(R.id.comment_button);
    ImageButton shareButton = (ImageButton) view.findViewById(R.id.share_button);
    ViewGroup buttonBar = (ViewGroup) view.findViewById(R.id.button_bar);
    PhotoHolder holder = new PhotoHolder(authorProfileImage, story, postTime, message, likeButton, commentButton, shareButton, buttonBar);
    setHolder(view, holder);
}
Also used : ImageButton(android.widget.ImageButton) ImageButton(android.widget.ImageButton) Button(android.widget.Button) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) ImageView(android.widget.ImageView) PhotoHolder(com.abewy.android.apps.klyph.adapter.holder.PhotoHolder)

Aggregations

ImageButton (android.widget.ImageButton)158 View (android.view.View)112 TextView (android.widget.TextView)87 ImageView (android.widget.ImageView)55 Button (android.widget.Button)27 ListView (android.widget.ListView)25 AdapterView (android.widget.AdapterView)24 OnClickListener (android.view.View.OnClickListener)21 LinearLayout (android.widget.LinearLayout)21 Intent (android.content.Intent)19 RelativeLayout (android.widget.RelativeLayout)13 DialogInterface (android.content.DialogInterface)12 Bundle (android.os.Bundle)11 LayoutInflater (android.view.LayoutInflater)11 EditText (android.widget.EditText)11 ViewGroup (android.view.ViewGroup)10 ArrayList (java.util.ArrayList)10 Builder (android.app.AlertDialog.Builder)7 Drawable (android.graphics.drawable.Drawable)7 RecyclerView (android.support.v7.widget.RecyclerView)7