use of android.view.View.OnClickListener in project platform_frameworks_base by android.
the class PrintErrorFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
CharSequence message = getArguments().getCharSequence(EXTRA_MESSAGE);
if (!TextUtils.isEmpty(message)) {
TextView messageView = (TextView) view.findViewById(R.id.message);
messageView.setText(message);
}
Button actionButton = (Button) view.findViewById(R.id.action_button);
final int action = getArguments().getInt(EXTRA_ACTION);
switch(action) {
case ACTION_RETRY:
{
actionButton.setVisibility(View.VISIBLE);
actionButton.setText(R.string.print_error_retry);
}
break;
case ACTION_NONE:
{
actionButton.setVisibility(View.GONE);
}
break;
}
actionButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Activity activity = getActivity();
if (activity instanceof OnActionListener) {
((OnActionListener) getActivity()).onActionPerformed();
}
}
});
}
use of android.view.View.OnClickListener in project platform_frameworks_base by android.
the class SelectPrinterActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActionBar().setIcon(R.drawable.ic_print);
setContentView(R.layout.select_printer_activity);
mEnabledPrintServices = new ArrayMap<>();
mPrinterRegistry = new PrinterRegistry(this, null, LOADER_ID_PRINT_REGISTRY, LOADER_ID_PRINT_REGISTRY_INT);
// Hook up the list view.
mListView = (ListView) findViewById(android.R.id.list);
final DestinationAdapter adapter = new DestinationAdapter();
adapter.registerDataSetObserver(new DataSetObserver() {
@Override
public void onChanged() {
if (!isFinishing() && adapter.getCount() <= 0) {
updateEmptyView(adapter);
}
}
@Override
public void onInvalidated() {
if (!isFinishing()) {
updateEmptyView(adapter);
}
}
});
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (!((DestinationAdapter) mListView.getAdapter()).isActionable(position)) {
return;
}
PrinterInfo printer = (PrinterInfo) mListView.getAdapter().getItem(position);
if (printer == null) {
startAddPrinterActivity();
} else {
onPrinterSelected(printer);
}
}
});
findViewById(R.id.button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startAddPrinterActivity();
}
});
registerForContextMenu(mListView);
getLoaderManager().initLoader(LOADER_ID_ENABLED_PRINT_SERVICES, null, this);
// If some are disabled and some are enabled show a toast to notify the user
if (savedInstanceState == null || !savedInstanceState.getBoolean(KEY_NOT_FIRST_CREATE)) {
List<PrintServiceInfo> allServices = ((PrintManager) getSystemService(Context.PRINT_SERVICE)).getPrintServices(PrintManager.ALL_SERVICES);
boolean hasEnabledServices = false;
boolean hasDisabledServices = false;
if (allServices != null) {
final int numServices = allServices.size();
for (int i = 0; i < numServices; i++) {
if (allServices.get(i).isEnabled()) {
hasEnabledServices = true;
} else {
hasDisabledServices = true;
}
}
}
if (!hasEnabledServices) {
startAddPrinterActivity();
} else if (hasDisabledServices) {
String disabledServicesSetting = Settings.Secure.getString(getContentResolver(), Settings.Secure.DISABLED_PRINT_SERVICES);
if (!TextUtils.isEmpty(disabledServicesSetting)) {
Toast.makeText(this, getString(R.string.print_services_disabled_toast), Toast.LENGTH_LONG).show();
}
}
}
}
use of android.view.View.OnClickListener in project platform_frameworks_base by android.
the class PrintActivity method bindUi.
private void bindUi() {
// Summary
mSummaryContainer = findViewById(R.id.summary_content);
mSummaryCopies = (TextView) findViewById(R.id.copies_count_summary);
mSummaryPaperSize = (TextView) findViewById(R.id.paper_size_summary);
// Options container
mOptionsContent = (PrintContentView) findViewById(R.id.options_content);
mOptionsContent.setOptionsStateChangeListener(this);
mOptionsContent.setOpenOptionsController(this);
OnItemSelectedListener itemSelectedListener = new MyOnItemSelectedListener();
OnClickListener clickListener = new MyClickListener();
// Copies
mCopiesEditText = (EditText) findViewById(R.id.copies_edittext);
mCopiesEditText.setOnFocusChangeListener(mSelectAllOnFocusListener);
mCopiesEditText.setText(MIN_COPIES_STRING);
mCopiesEditText.setSelection(mCopiesEditText.getText().length());
mCopiesEditText.addTextChangedListener(new EditTextWatcher());
// Destination.
mPrintersObserver = new PrintersObserver();
mDestinationSpinnerAdapter.registerDataSetObserver(mPrintersObserver);
mDestinationSpinner = (Spinner) findViewById(R.id.destination_spinner);
mDestinationSpinner.setAdapter(mDestinationSpinnerAdapter);
mDestinationSpinner.setOnItemSelectedListener(itemSelectedListener);
// Media size.
mMediaSizeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mMediaSizeSpinner = (Spinner) findViewById(R.id.paper_size_spinner);
mMediaSizeSpinner.setAdapter(mMediaSizeSpinnerAdapter);
mMediaSizeSpinner.setOnItemSelectedListener(itemSelectedListener);
// Color mode.
mColorModeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mColorModeSpinner = (Spinner) findViewById(R.id.color_spinner);
mColorModeSpinner.setAdapter(mColorModeSpinnerAdapter);
mColorModeSpinner.setOnItemSelectedListener(itemSelectedListener);
// Duplex mode.
mDuplexModeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mDuplexModeSpinner = (Spinner) findViewById(R.id.duplex_spinner);
mDuplexModeSpinner.setAdapter(mDuplexModeSpinnerAdapter);
mDuplexModeSpinner.setOnItemSelectedListener(itemSelectedListener);
// Orientation
mOrientationSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
String[] orientationLabels = getResources().getStringArray(R.array.orientation_labels);
mOrientationSpinnerAdapter.add(new SpinnerItem<>(ORIENTATION_PORTRAIT, orientationLabels[0]));
mOrientationSpinnerAdapter.add(new SpinnerItem<>(ORIENTATION_LANDSCAPE, orientationLabels[1]));
mOrientationSpinner = (Spinner) findViewById(R.id.orientation_spinner);
mOrientationSpinner.setAdapter(mOrientationSpinnerAdapter);
mOrientationSpinner.setOnItemSelectedListener(itemSelectedListener);
// Range options
ArrayAdapter<SpinnerItem<Integer>> rangeOptionsSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mRangeOptionsSpinner = (Spinner) findViewById(R.id.range_options_spinner);
mRangeOptionsSpinner.setAdapter(rangeOptionsSpinnerAdapter);
mRangeOptionsSpinner.setOnItemSelectedListener(itemSelectedListener);
updatePageRangeOptions(PrintDocumentInfo.PAGE_COUNT_UNKNOWN);
// Page range
mPageRangeTitle = (TextView) findViewById(R.id.page_range_title);
mPageRangeEditText = (EditText) findViewById(R.id.page_range_edittext);
mPageRangeEditText.setVisibility(View.INVISIBLE);
mPageRangeTitle.setVisibility(View.INVISIBLE);
mPageRangeEditText.setOnFocusChangeListener(mSelectAllOnFocusListener);
mPageRangeEditText.addTextChangedListener(new RangeTextWatcher());
// Advanced options button.
mMoreOptionsButton = (Button) findViewById(R.id.more_options_button);
mMoreOptionsButton.setOnClickListener(clickListener);
// Print button
mPrintButton = (ImageView) findViewById(R.id.print_button);
mPrintButton.setOnClickListener(clickListener);
// The UI is now initialized
mIsOptionsUiBound = true;
// Special prompt instead of destination spinner for the first time the user printed
if (!hasUserEverPrinted()) {
mShowDestinationPrompt = true;
mSummaryCopies.setEnabled(false);
mSummaryPaperSize.setEnabled(false);
mDestinationSpinner.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
mShowDestinationPrompt = false;
mSummaryCopies.setEnabled(true);
mSummaryPaperSize.setEnabled(true);
updateOptionsUi();
mDestinationSpinner.setOnTouchListener(null);
mDestinationSpinnerAdapter.notifyDataSetChanged();
return false;
}
});
}
}
use of android.view.View.OnClickListener in project Conversations by siacs.
the class MessageAdapter method displayOpenableMessage.
private void displayOpenableMessage(ViewHolder viewHolder, final Message message) {
viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.GONE);
viewHolder.download_button.setVisibility(View.VISIBLE);
viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message)));
viewHolder.download_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openDownloadable(message);
}
});
}
use of android.view.View.OnClickListener in project Conversations by siacs.
the class MessageAdapter method displayLocationMessage.
private void displayLocationMessage(ViewHolder viewHolder, final Message message) {
viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.GONE);
viewHolder.download_button.setVisibility(View.VISIBLE);
viewHolder.download_button.setText(R.string.show_location);
viewHolder.download_button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showLocation(message);
}
});
}
Aggregations