本文整理汇总了Java中android.widget.RemoteViews.setOnClickFillInIntent方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setOnClickFillInIntent方法的具体用法?Java RemoteViews.setOnClickFillInIntent怎么用?Java RemoteViews.setOnClickFillInIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setOnClickFillInIntent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
Log.v(TAG, "getViewAt: position = " + position);
// Construct a remote views item based on the app widget item XML file,
// and set the text based on the position.
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_list_item);
Intent fillInIntent = new Intent();
fillInIntent.putExtra(EXTRA_LIST_VIEW_ROW_NUMBER, position);
rv.setOnClickFillInIntent(R.id.main_list_item, fillInIntent);
rv.setTextViewText(R.id.w_author_name, widgetDatas.get(position).getAuthorName());
rv.setTextViewText(R.id.w_title, widgetDatas.get(position).getTitle());
Picasso pic = Picasso.with(context);
try {
Bitmap map = pic.load(widgetDatas.get(position).getAvatar()).get();
rv.setImageViewBitmap(R.id.w_github_user_image, map);
} catch (IOException e) {
Log.e(TAG, "", e);
}
return rv;
}
示例2: loadItemOnClickExtras
import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
* Item设置点击事件
* @param rv
* @param position
*/
private void loadItemOnClickExtras(RemoteViews rv, int position) {
/*
* 为每一个item都设置pendingIntent是很繁琐的,需要很多很多的pendingIntent,因此不允许这样做。
* 之前在provider,通过setPendingIntentTemplate()我们已经为整个remote
* list统一设置了item点击触发的 pendingintent模板。
* setOnClickFillInIntent()在模板的基础上为具体的item设置fillInIntent,
* fillInIntent会加入到PendingIntent模板中。
* 每个item触发,相同的部分在模板,不同的部分在fillInIntent
*/
Logger.INSTANCE.i(" --> loadItemOnClickExtras");
Intent intent = new Intent();
intent.putExtra(AppWidgetNotesProvider.Companion.getNOTES_ITEM_CLICK_ACTION(),
position);
rv.setOnClickFillInIntent(R.id.ic_notes_item_ll, intent);
}
示例3: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews row=new RemoteViews(ctxt.getPackageName(),
R.layout.widget_tasklist_row);
Log.d("taskViewsFactory","getViewAt called, data: "+mainList.get(position).getTask()+" "+row+" "+R.id.textView);
row.setTextViewText(R.id.textView, mainList.get(position).getTask());
Intent i=new Intent();
Bundle extras=new Bundle();
extras.putString(WidgetHandler.EXTRA_WORD, mainList.get(position).getTask());
i.putExtras(extras);
row.setOnClickFillInIntent(R.id.textView, i);
return(row);
}
示例4: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.message_list_widget_list_item);
MailItem item = mailItems.get(position);
CharSequence sender = item.unread ? bold(item.sender) : item.sender;
CharSequence subject = item.unread ? bold(item.subject) : item.subject;
if (senderAboveSubject) {
remoteView.setTextViewText(R.id.sender, sender);
remoteView.setTextViewText(R.id.mail_subject, subject);
} else {
remoteView.setTextViewText(R.id.sender, subject);
remoteView.setTextViewText(R.id.mail_subject, sender);
}
remoteView.setTextViewText(R.id.mail_date, item.getDateFormatted("%d %s"));
remoteView.setTextViewText(R.id.mail_preview, item.preview);
int textColor = item.getTextColor();
remoteView.setTextColor(R.id.sender, textColor);
remoteView.setTextColor(R.id.mail_subject, textColor);
remoteView.setTextColor(R.id.mail_date, textColor);
remoteView.setTextColor(R.id.mail_preview, textColor);
if (item.hasAttachment) {
remoteView.setInt(R.id.attachment, "setVisibility", View.VISIBLE);
} else {
remoteView.setInt(R.id.attachment, "setVisibility", View.GONE);
}
Intent intent = new Intent();
intent.setData(item.uri);
remoteView.setOnClickFillInIntent(R.id.mail_list_item, intent);
return remoteView;
}
示例5: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
public RemoteViews getViewAt(int position) {
File file = new File(Environment.getExternalStoragePublicDirectory("/"+mContext.getResources().getString(R.string.app_name)), mWidgetItems.get(position).getId() +mContext.getResources().getString(R.string.jpg) );
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(file.getPath(), options);
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
rv.setImageViewBitmap(R.id.widget_item,Bitmap.createScaledBitmap(bitmap, 450,300, false));
Bundle extras = new Bundle();
extras.putInt(StackWidgetProvider.EXTRA_ITEM, position);
Intent fillInIntent = new Intent();
fillInIntent.putExtras(extras);
rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);
try {
System.out.println(mContext.getResources().getString(R.string.Loading_view) + position);
Thread.sleep(500);
} catch (InterruptedException e) {
MyApplication.getInstance().trackException(e);
e.printStackTrace();
}
return rv;
}
示例6: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews remoteViews = new RemoteViews(
context.getPackageName(), R.layout.item_package_for_widget);
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(DATABASE_NAME)
.build());
List<Package> results = rlm.copyFromRealm(rlm.where(Package.class)
.notEqualTo("state", String.valueOf(Package.STATUS_DELIVERED))
.findAllSorted("timestamp", Sort.DESCENDING));
Package p = results.get(position);
if (p.getData() != null && p.getData().size() > 0) {
int state = Integer.parseInt(p.getState());
remoteViews.setTextViewText(R.id.textViewStatus,
String.valueOf(packageStatus[state]) + " - " + p.getData().get(0).getContext());
remoteViews.setTextViewText(R.id.textViewTime, p.getData().get(0).getTime());
} else {
remoteViews.setTextViewText(R.id.textViewTime, "");
remoteViews.setTextViewText(R.id.textViewStatus, statusError);
}
remoteViews.setTextViewText(R.id.textViewPackageName, p.getName());
remoteViews.setTextViewText(R.id.textViewAvatar, p.getName().substring(0, 1));
remoteViews.setImageViewResource(R.id.imageViewAvatar, p.getColorAvatar());
Intent intent = new Intent();
intent.putExtra(PackageDetailsActivity.PACKAGE_ID, p.getNumber());
remoteViews.setOnClickFillInIntent(R.id.layoutPackageItemMain, intent);
return remoteViews;
}
示例7: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews rowView = new RemoteViews(_context.getPackageName(), R.layout.widget_file_item);
rowView.setTextViewText(R.id.widget_note_title, "???");
if (position < _widgetFilesList.length) {
File file = _widgetFilesList[position];
Intent fillInIntent = new Intent().putExtra(DocumentIO.EXTRA_PATH, file);
rowView.setTextViewText(R.id.widget_note_title, MarkdownTextConverter.MD_EXTENSION_PATTERN.matcher(file.getName()).replaceAll(""));
rowView.setOnClickFillInIntent(R.id.widget_note_title, fillInIntent);
}
return rowView;
}
示例8: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.queue_widget_listview_layout);
if (position <= getCount()) {
String songTitle = songs.get(position)._title;
ImageSize imageSize = new ImageSize(75, 75);
long songDurationInMillis = 0;
try {
songDurationInMillis = songs.get(position)._duration;
} catch (Exception e) {
}
remoteViews.setTextViewText(R.id.listViewSubText, songTitle);
remoteViews.setTextViewText(R.id.listViewRightSubText, MusicUtils.convertMillisToMinsSecs(songDurationInMillis));
Bitmap bitmap = ImageLoader.getInstance().loadImageSync(String.valueOf(MusicUtils.getAlbumArtUri(mApp.getService().getSongList().get(position)._albumId)), imageSize);
if (bitmap != null) {
remoteViews.setImageViewBitmap(R.id.listViewLeftIcon, bitmap);
} else {
remoteViews.setImageViewResource(R.id.listViewLeftIcon, R.mipmap.ic_launcher);
}
}
/* This intent latches itself onto the pendingIntentTemplate from
* LargeWidgetProvider.java and adds the extra "INDEX" argument to it. */
Intent fillInIntent = new Intent();
fillInIntent.putExtra("INDEX", position);
remoteViews.setOnClickFillInIntent(R.id.listViewParent, fillInIntent);
return remoteViews;
}
示例9: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews remoteViews = new RemoteViews(applicationContext.getPackageName(),
R.layout.ingredients_widget_list_item);
remoteViews.setTextViewText(R.id.ingredient_list_item_text_view,
ingredientsDescription.get(position));
Intent fillIntent = new Intent();
remoteViews.setOnClickFillInIntent(R.id.ingredient_list_item_text_view, fillIntent);
return remoteViews;
}
示例10: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, "getViewAt", position);
Note note = null;
if (mCursor.moveToPosition(position)) {
note = NotesClient.fromCursor(mCursor);
}
RemoteViews row = new RemoteViews(mContext.getPackageName(), R.layout.item_list_widget);
if (note != null) {
setContent(row, note);
final Intent openIntent = new Intent();
openIntent.putExtra(AppIntent.EXTRA_CLICK_TYPE, ListWidgetProvider.OPEN_CLICK_TYPE);
openIntent.putExtra(AppIntent.EXTRA_NOTE_ID, note.getId());
openIntent.putExtra(AppIntent.EXTRA_BOOK_ID, note.getPosition().getBookId());
row.setOnClickFillInIntent(R.id.item_list_widget_layout, openIntent);
final Intent doneIntent = new Intent();
doneIntent.putExtra(AppIntent.EXTRA_CLICK_TYPE, ListWidgetProvider.DONE_CLICK_TYPE);
doneIntent.putExtra(AppIntent.EXTRA_NOTE_ID, note.getId());
row.setOnClickFillInIntent(R.id.item_list_widget_done, doneIntent);
}
return row;
}
示例11: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews row = new RemoteViews(mContext.getPackageName(), R.layout.widget_profile_item);
row.setTextViewText(R.id.text, mItems.get(position).getName());
Intent i = new Intent();
Bundle extras = new Bundle();
extras.putInt(ITEM_ARG, position);
i.putExtras(extras);
row.setOnClickFillInIntent(R.id.text, i);
return (row);
}
示例12: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews remoteView = new RemoteViews(mContext.getPackageName(), R.layout.desktop_widget_item);
Schedule item = mData.get(position);
remoteView.setTextViewText(R.id.widget_item_name, item.getName());
remoteView.setTextViewText(R.id.widget_item_time, item.getStartSec()+"-"+item.getEndSec());
remoteView.setTextViewText(R.id.widget_item_location, item.getLocation());
// item点击事件调到app,setOnClickFillInIntent的第一个id为item布局的根布局,需要先在CourseAppWidgetProvider调用了setPendingIntentTemplate才生效
Intent intent = new Intent(mContext, MainActivity.class);
remoteView.setOnClickFillInIntent(R.id.desktop_widget_layout_item, intent);
return remoteView;
}
示例13: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
public RemoteViews getViewAt(int position) {
// position will always range from 0 to getCount() - 1.
// We construct a remote views item based on our widget item xml file, and set the
// text based on the position.
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
rv.setTextViewText(R.id.widget_item, mWidgetItems.get(position).text);
// Next, we set a fill-intent which will be used to fill-in the pending intent template
// which is set on the collection view in StackWidgetProvider.
Bundle extras = new Bundle();
extras.putInt(StackWidgetProvider.EXTRA_ITEM, position);
Intent fillInIntent = new Intent();
fillInIntent.putExtras(extras);
rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);
// You can do heaving lifting in here, synchronously. For example, if you need to
// process an image, fetch something from the network, etc., it is ok to do it here,
// synchronously. A loading view will show up in lieu of the actual contents in the
// interim.
try {
System.out.println("Loading view " + position);
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Return the remote views object.
return rv;
}
示例14: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
public RemoteViews getViewAt(int position) {
// Get the data for this position from the content provider
String day = "Unknown Day";
int temp = 0;
if (mCursor.moveToPosition(position)) {
final int dayColIndex = mCursor.getColumnIndex(WeatherDataProvider.Columns.DAY);
final int tempColIndex = mCursor.getColumnIndex(
WeatherDataProvider.Columns.TEMPERATURE);
day = mCursor.getString(dayColIndex);
temp = mCursor.getInt(tempColIndex);
}
// Return a proper item with the proper day and temperature
final String formatStr = mContext.getResources().getString(R.string.item_format_string);
final int itemId = R.layout.widget_item;
RemoteViews rv = new RemoteViews(mContext.getPackageName(), itemId);
rv.setTextViewText(R.id.widget_item, String.format(formatStr, temp, day));
// Set the click intent so that we can handle it and show a toast message
final Intent fillInIntent = new Intent();
final Bundle extras = new Bundle();
extras.putString(WeatherWidgetProvider.EXTRA_DAY_ID, day);
fillInIntent.putExtras(extras);
rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);
return rv;
}
示例15: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
if (position < mItems.size()) {
String category = mItems.get(position).getCategory();
if (category == null || category.equals("")) {
rv.setTextViewText(R.id.category, getString(R.string.edit_category_empty));
} else {
rv.setTextViewText(R.id.category, category);
}
String type = mItems.get(position).getType();
if (type == null || type.equals("")) {
rv.setTextViewText(R.id.type, getString(R.string.edit_type_empty));
} else {
rv.setTextViewText(R.id.type, type);
}
String colour = mItems.get(position).getMainColour();
if (colour == null || colour.equals("")) {
rv.setTextViewText(R.id.colour, getString(R.string.edit_main_colour_empty));
} else {
rv.setTextViewText(R.id.colour, colour);
}
long expiry = mItems.get(position).getExpiry();
if (expiry == -1) {
setTextColourPrimary(rv);
rv.setTextViewText(R.id.expiry, getString(R.string.edit_expiry_date_empty));
} else {
Calendar expiryDate = Calendar.getInstance();
expiryDate.setTimeInMillis(expiry);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(getString(
R.string.edit_date_format),
Locale.ENGLISH);
String expiryString = simpleDateFormat.format(expiryDate.getTime());
rv.setTextViewText(R.id.expiry, expiryString);
Calendar almostExpiredDate = Calendar.getInstance();
almostExpiredDate.add(Calendar.MONTH, 1);
if (expiryDate.compareTo(Calendar.getInstance()) < 1) {
rv.setInt(R.id.expiry, "setTextColor", ContextCompat.getColor(mContext,
R.color.red));
} else if (expiryDate.compareTo(almostExpiredDate) < 1) {
rv.setInt(R.id.expiry, "setTextColor", ContextCompat.getColor(mContext,
R.color.orange));
} else {
setTextColourPrimary(rv);
}
}
int price = mItems.get(position).getPricePaid();
String priceString;
if (price == -1) {
priceString = getString(R.string.edit_price_paid_empty);
} else {
priceString = getString(R.string.edit_price_paid_prefix)
+ getPriceFromTotalCents(price);
}
rv.setTextViewText(R.id.paid, priceString);
Intent fillInIntent = new Intent();
fillInIntent.putExtra(EXTRA_ITEM_ID, mItems.get(position).getId());
rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);
}
return rv;
}