use of android.view.View.OnClickListener in project photo-picker-plus-android by chute.
the class ServicesRecyclerAdapter method setupLocalService.
private void setupLocalService(ListItemViewHolder holder, LocalServiceType type) {
Uri lastVideoThumbFromAllVideos = MediaDAO.getLastVideoThumbnailFromAllVideos(context.getApplicationContext());
Uri lastVideoThumbFromCameraVideos = MediaDAO.getLastVideoThumbnailFromCameraVideos(context.getApplicationContext());
Uri lastImageFromAllPhotos = MediaDAO.getLastPhotoFromAllPhotos(context.getApplicationContext());
Uri lastImageFromCameraPhotos = MediaDAO.getLastPhotoFromCameraPhotos(context.getApplicationContext());
switch(type) {
case TAKE_PHOTO:
holder.imageViewService.setBackgroundResource(R.drawable.take_photo);
holder.textViewServiceTitle.setText(R.string.take_photos);
break;
case CAMERA_MEDIA:
Uri uriCameraMedia = null;
if (supportsImages) {
uriCameraMedia = lastImageFromAllPhotos;
} else {
uriCameraMedia = lastVideoThumbFromCameraVideos;
}
Picasso.with(context).load(uriCameraMedia).fit().centerCrop().into(holder.imageViewService);
holder.textViewServiceTitle.setText(R.string.camera_media);
break;
case LAST_PHOTO_TAKEN:
Picasso.with(context).load(lastImageFromAllPhotos).fit().centerCrop().into(holder.imageViewService);
holder.textViewServiceTitle.setText(context.getResources().getString(R.string.last_photo));
break;
case ALL_MEDIA:
Uri uriAllMedia = null;
if (supportsImages) {
uriAllMedia = lastImageFromAllPhotos;
} else {
uriAllMedia = lastVideoThumbFromAllVideos;
}
Picasso.with(context).load(uriAllMedia).fit().centerCrop().into(holder.imageViewService);
holder.textViewServiceTitle.setText(context.getResources().getString(R.string.all_media));
break;
case LAST_VIDEO_CAPTURED:
String thumbnail = MediaDAO.getLastVideoThumbnailFromCurosr(context);
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(thumbnail, MediaStore.Images.Thumbnails.MINI_KIND);
holder.imageViewService.setImageBitmap(bitmap);
holder.textViewServiceTitle.setText(context.getResources().getString(R.string.last_video_captured));
break;
case RECORD_VIDEO:
holder.imageViewService.setBackgroundResource(R.drawable.take_photo);
holder.textViewServiceTitle.setText(R.string.record_video);
break;
}
/* Click listeners */
switch(type) {
case ALL_MEDIA:
holder.imageViewService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
serviceClickedListener.photoStream();
}
});
break;
case CAMERA_MEDIA:
holder.imageViewService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
serviceClickedListener.cameraRoll();
}
});
break;
case TAKE_PHOTO:
holder.imageViewService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
serviceClickedListener.takePhoto();
}
});
break;
case LAST_PHOTO_TAKEN:
holder.imageViewService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
serviceClickedListener.lastPhoto();
}
});
break;
case LAST_VIDEO_CAPTURED:
holder.imageViewService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
serviceClickedListener.lastVideo();
}
});
break;
case RECORD_VIDEO:
holder.imageViewService.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
serviceClickedListener.recordVideo();
}
});
break;
}
}
use of android.view.View.OnClickListener in project UltimateAndroid by cymcsg.
the class MaterialDesignActivity method onCreate.
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.material_design_activity_main);
buttonSelectColor = (ButtonFloatSmall) findViewById(R.id.buttonColorSelector);
buttonSelectColor.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
ColorSelector colorSelector = new ColorSelector(MaterialDesignActivity.this, backgroundColor, MaterialDesignActivity.this);
colorSelector.show();
}
});
LayoutRipple layoutRipple = (LayoutRipple) findViewById(R.id.itemButtons);
setOriginRiple(layoutRipple);
layoutRipple.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(MaterialDesignActivity.this, ButtonsActivity.class);
intent.putExtra("BACKGROUND", backgroundColor);
startActivity(intent);
}
});
layoutRipple = (LayoutRipple) findViewById(R.id.itemSwitches);
setOriginRiple(layoutRipple);
layoutRipple.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(MaterialDesignActivity.this, SwitchActivity.class);
intent.putExtra("BACKGROUND", backgroundColor);
startActivity(intent);
}
});
layoutRipple = (LayoutRipple) findViewById(R.id.itemProgress);
setOriginRiple(layoutRipple);
layoutRipple.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(MaterialDesignActivity.this, ProgressActivity.class);
intent.putExtra("BACKGROUND", backgroundColor);
startActivity(intent);
}
});
layoutRipple = (LayoutRipple) findViewById(R.id.itemWidgets);
setOriginRiple(layoutRipple);
layoutRipple.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(MaterialDesignActivity.this, WidgetActivity.class);
intent.putExtra("BACKGROUND", backgroundColor);
startActivity(intent);
}
});
}
use of android.view.View.OnClickListener in project android-betterpickers by code-troopers.
the class CalendarDatePickerDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d(TAG, "onCreateView: ");
if (getShowsDialog()) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
View view = inflater.inflate(R.layout.calendar_date_picker_dialog, container, false);
mSelectedDateLayout = (LinearLayout) view.findViewById(R.id.day_picker_selected_date_layout);
mDayOfWeekView = (TextView) view.findViewById(R.id.date_picker_header);
mMonthAndDayView = (LinearLayout) view.findViewById(R.id.date_picker_month_and_day);
mMonthAndDayView.setOnClickListener(this);
mSelectedMonthTextView = (TextView) view.findViewById(R.id.date_picker_month);
mSelectedDayTextView = (TextView) view.findViewById(R.id.date_picker_day);
mYearView = (TextView) view.findViewById(R.id.date_picker_year);
mYearView.setOnClickListener(this);
int listPosition = -1;
int listPositionOffset = 0;
int currentView = MONTH_AND_DAY_VIEW;
if (savedInstanceState != null) {
mWeekStart = savedInstanceState.getInt(KEY_WEEK_START);
mMinDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_START));
mMaxDate = new CalendarDay(savedInstanceState.getLong(KEY_DATE_END));
currentView = savedInstanceState.getInt(KEY_CURRENT_VIEW);
listPosition = savedInstanceState.getInt(KEY_LIST_POSITION);
listPositionOffset = savedInstanceState.getInt(KEY_LIST_POSITION_OFFSET);
mStyleResId = savedInstanceState.getInt(KEY_THEME);
mDisabledDays = savedInstanceState.getSparseParcelableArray(KEY_DISABLED_DAYS);
}
final Activity activity = getActivity();
mDayPickerView = new SimpleDayPickerView(activity, this);
mYearPickerView = new YearPickerView(activity, this);
Resources res = getResources();
TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersDialogs);
mDayPickerDescription = res.getString(R.string.day_picker_description);
mSelectDay = res.getString(R.string.select_day);
mYearPickerDescription = res.getString(R.string.year_picker_description);
mSelectYear = res.getString(R.string.select_year);
int headerBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int preHeaderBackgroundColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpPreHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor, ContextCompat.getColor(getActivity(), R.color.bpBlue));
mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor, ContextCompat.getColor(getActivity(), R.color.radial_gray_light));
mAnimator = (AccessibleDateAnimator) view.findViewById(R.id.animator);
mAnimator.addView(mDayPickerView);
mAnimator.addView(mYearPickerView);
mAnimator.setDateMillis(mCalendar.getTimeInMillis());
// TODO: Replace with animation decided upon by the design team.
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(ANIMATION_DURATION);
mAnimator.setInAnimation(animation);
// TODO: Replace with animation decided upon by the design team.
Animation animation2 = new AlphaAnimation(1.0f, 0.0f);
animation2.setDuration(ANIMATION_DURATION);
mAnimator.setOutAnimation(animation2);
Button doneButton = (Button) view.findViewById(R.id.done_button);
if (mDoneText != null) {
doneButton.setText(mDoneText);
}
doneButton.setTextColor(buttonTextColor);
doneButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tryVibrate();
if (mCallBack != null) {
mCallBack.onDateSet(CalendarDatePickerDialogFragment.this, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));
}
dismiss();
}
});
Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
if (mCancelText != null) {
cancelButton.setText(mCancelText);
}
cancelButton.setTextColor(buttonTextColor);
cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tryVibrate();
dismiss();
}
});
view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);
updateDisplay(false);
setCurrentView(currentView);
if (listPosition != -1) {
if (currentView == MONTH_AND_DAY_VIEW) {
mDayPickerView.postSetSelection(listPosition);
} else if (currentView == YEAR_VIEW) {
mYearPickerView.postSetSelectionFromTop(listPosition, listPositionOffset);
}
}
mHapticFeedbackController = new HapticFeedbackController(activity);
mDayPickerView.setTheme(themeColors);
mYearPickerView.setTheme(themeColors);
mSelectedDateLayout.setBackgroundColor(headerBackgroundColor);
mYearView.setBackgroundColor(headerBackgroundColor);
mMonthAndDayView.setBackgroundColor(headerBackgroundColor);
if (mDayOfWeekView != null) {
mDayOfWeekView.setBackgroundColor(preHeaderBackgroundColor);
}
view.setBackgroundColor(bodyBgColor);
mYearPickerView.setBackgroundColor(bodyBgColor);
mDayPickerView.setBackgroundColor(bodyBgColor);
return view;
}
use of android.view.View.OnClickListener in project android by cSploit.
the class PortScanner method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
Boolean isDark = themePrefs.getBoolean("isDark", false);
if (isDark)
setTheme(R.style.DarkTheme);
else
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
mPreferences = System.getSettings();
mTextDoc = (TextView) findViewById(R.id.scanDoc);
mTextParameters = (EditText) findViewById(R.id.scanParameters);
mScanFloatingActionButton = (FloatingActionButton) findViewById(R.id.scanToggleButton);
mScanProgress = (ProgressBar) findViewById(R.id.scanActivity);
mShowCustomParameters = mPreferences.getBoolean(CUSTOM_PARAMETERS, false);
if (mShowCustomParameters)
displayParametersField();
else
hideParametersField();
mScanFloatingActionButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mRunning) {
setStoppedState();
} else {
setStartedState();
}
}
});
ListView mScanList = (ListView) findViewById(R.id.scanListView);
createPortList();
final Target target = System.getCurrentTarget();
final String cmdlineRep = target.getCommandLineRepresentation();
mScanReceiver = new Receiver(target);
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mPortList);
mScanList.setAdapter(mListAdapter);
mScanList.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
int portNumber = target.getOpenPorts().get(position).getNumber();
if (!urlFormats.containsKey(portNumber)) {
portNumber = 0;
}
final String url = String.format(urlFormats.get(portNumber), cmdlineRep, portNumber);
new ConfirmDialog("Open", "Open " + url + " ?", PortScanner.this, new ConfirmDialogListener() {
@Override
public void onConfirm() {
try {
Intent browser = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
PortScanner.this.startActivity(browser);
} catch (ActivityNotFoundException e) {
System.errorLogging(e);
new ErrorDialog(getString(R.string.error), getString(R.string.no_activities_for_url), PortScanner.this).show();
}
}
@Override
public void onCancel() {
}
}).show();
return false;
}
});
}
use of android.view.View.OnClickListener in project android by cSploit.
the class Hijacker method onCreate.
public void onCreate(Bundle savedInstanceState) {
SharedPreferences themePrefs = getSharedPreferences("THEME", 0);
Boolean isDark = themePrefs.getBoolean("isDark", false);
if (isDark)
setTheme(R.style.DarkTheme);
else
setTheme(R.style.AppTheme);
super.onCreate(savedInstanceState);
setTitle(System.getCurrentTarget() + " > MITM > " + getString(R.string.session_sniffer));
setContentView(R.layout.plugin_mitm_hijacker);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mHijackToggleButton = (ToggleButton) findViewById(R.id.hijackToggleButton);
mHijackProgress = (ProgressBar) findViewById(R.id.hijackActivity);
ListView mListView = (ListView) findViewById(R.id.listView);
mAdapter = new SessionListAdapter(R.layout.plugin_mitm_hijacker_list_item);
mSpoof = new SpoofSession();
mListView.setAdapter(mAdapter);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final Session session = mAdapter.getByPosition(position);
if (session != null) {
new ConfirmDialog(getString(R.string.hijack_session), mRunning ? getString(R.string.start_hijacking) : getString(R.string.start_hijacking2), Hijacker.this, new ConfirmDialogListener() {
@Override
public void onConfirm() {
if (mRunning)
setStoppedState();
System.setCustomData(session);
startActivity(new Intent(Hijacker.this, HijackerWebView.class));
}
@Override
public void onCancel() {
}
}).show();
}
}
});
mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
final Session session = mAdapter.getByPosition(position);
if (session != null) {
new InputDialog(getString(R.string.save_session), getString(R.string.set_session_filename), session.getFileName(), true, false, Hijacker.this, new InputDialogListener() {
@Override
public void onInputEntered(String name) {
if (!name.isEmpty()) {
try {
String filename = session.save(name);
Toast.makeText(Hijacker.this, getString(R.string.session_saved_to) + filename + " .", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
new ErrorDialog(getString(R.string.error), e.toString(), Hijacker.this).show();
}
} else
new ErrorDialog(getString(R.string.error), getString(R.string.invalid_session), Hijacker.this).show();
}
}).show();
}
return true;
}
});
mHijackToggleButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mRunning) {
setStoppedState();
} else {
setStartedState();
}
}
});
mRequestListener = new RequestListener();
}
Aggregations