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();
}
}
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);
}
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);
}
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;
}
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);
}
Aggregations