本文整理汇总了Java中com.google.android.apps.dashclock.api.ExtensionData类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionData类的具体用法?Java ExtensionData怎么用?Java ExtensionData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionData类属于com.google.android.apps.dashclock.api包,在下文中一共展示了ExtensionData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
// Get preference value.
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
String name = sp.getString(PREF_NAME, getString(R.string.pref_name_default));
// Publish the extension data update.
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.drawable.ic_extension_example)
.status("Hello")
.expandedTitle("Hello, " + name + "!")
.expandedBody("Thanks for checking out this example extension for DashClock.")
.contentDescription("Completely different text for accessibility if needed.")
.clickIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"))));
}
示例2: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
String nextAlarm = Settings.System.getString(getContentResolver(),
Settings.System.NEXT_ALARM_FORMATTED);
if (!TextUtils.isEmpty(nextAlarm)) {
Matcher m = sDigitPattern.matcher(nextAlarm);
if (m.find() && m.start() > 0) {
nextAlarm = nextAlarm.substring(0, m.start()) + "\n"
+ nextAlarm.substring(m.start() + 1); // +1 to skip whitespace
}
}
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
Intent alarmIntent = AppChooserPreference.getIntentValue(
sp.getString(PREF_ALARM_SHORTCUT, null), null);
if (alarmIntent == null) {
alarmIntent = Utils.getDefaultAlarmsIntent(this);
}
publishUpdate(new ExtensionData()
.visible(!TextUtils.isEmpty(nextAlarm))
.icon(R.drawable.ic_extension_next_alarm)
.status(nextAlarm)
.clickIntent(alarmIntent));
}
示例3: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
Countdown countdown = new Countdown(this, getCountdownNumber());
int[] diffs = countdown.getTimeRemaining();
ExtensionData extensionData = new ExtensionData();
extensionData.status(countdown.getStatus(diffs));
extensionData.expandedTitle(sharedPreferences.getString("pref_title_" + getCountdownNumber(), getString(R.string.no_countdown_title)));
extensionData.expandedBody(countdown.getBody(diffs));
extensionData.icon(sharedPreferences.getInt("pref_icon_" + getCountdownNumber(), R.drawable.ic_launcher));
extensionData.clickIntent(getClickIntent());
extensionData.visible(true);
publishUpdate(extensionData);
}
示例4: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
/**
* On update, retrieves a line status update, and populates an ExtensionData object
* ready for publication. The data object my be empty if there are no updates, or may
* be populated with some error details if we can't get the status for some reason.
*/
@Override
protected void onUpdateData(int reason) {
ExtensionData data = new ExtensionData();
if (shouldGetUpdates()) {
try {
GenericUrl url = new GenericUrl(getString(R.string.line_status_api_url));
HttpTransport transport = new NetHttpTransport();
HttpRequest req = transport.createRequestFactory().buildGetRequest(url);
HttpResponse rsp = req.execute();
data = processResponse(rsp);
rsp.disconnect();
} catch (IOException ioe) {
// Some kind of connection issue
data = populateExtensionData(R.string.error_status,
R.string.error_status,
getString(R.string.error_request_expanded_body),
null);
}
}
publishUpdate(data);
}
示例5: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int arg0) {
try {
Context context = getApplicationContext();
MmexApplication app = new MmexApplication();
CurrencyService currencyService = new CurrencyService(context);
// summary formatted
String summary = currencyService.getBaseCurrencyFormatted(
MoneyFactory.fromDouble(app.getSummaryAccounts(context)));
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.drawable.ic_stat_notification)
.status(summary)
.expandedTitle(context.getString(R.string.summary) + ": " + summary)
.expandedBody(app.getUserName())
.clickIntent(new Intent(this, MainActivity.class)));
} catch (Exception e) {
Timber.e(e, "updating summary dash extension");
}
}
示例6: createFrom
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
public ExtensionData createFrom(Error error) {
ExtensionData data = new ExtensionData();
data.status(mContext.getString(R.string.error_status)).icon(R.drawable.ic_skype).visible(true);
if (error == Error.NOTIFICATION_ACCESS) {
data.expandedTitle(mContext.getString(R.string.error_notification_access_title))
.expandedBody(mContext.getString(R.string.error_notification_access_body))
.clickIntent(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
} else if (error == Error.EXTENSION_ACCESS) {
data.expandedTitle(mContext.getString(R.string.error_extension_access_title))
.expandedBody(mContext.getString(R.string.error_extension_access_body)).clickIntent(new Intent(mContext, SettingsActivity.class));
}
return data;
}
示例7: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
ContentResolver resolver = getContentResolver();
boolean autoOrientationEnabled = getAutoOrientationEnabled(resolver);
if (reason == UPDATE_REASON_MANUAL) {
setAutoOrientationEnabled(resolver, !autoOrientationEnabled);
autoOrientationEnabled = getAutoOrientationEnabled(resolver);
}
publishUpdate(new ExtensionData()
.visible(true)
.icon(autoOrientationEnabled ? R.drawable.ic_auto_rotate_on : R.drawable.ic_auto_rotate_off)
.status(autoOrientationEnabled ? "ON" : "OFF")
.expandedTitle("Auto-rotate screen - " + (autoOrientationEnabled ? "On" : "Off")));
}
示例8: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@SuppressLint("DefaultLocale")
@Override
protected void onUpdateData(int reason) {
DbHelper db = DbHelper.getInstance(this);
int notes = db.getAllNotes(false).size();
int remindersTotal = db.getNotesWithReminder(true).size();
int remindersNotExpired = db.getNotesWithReminder(false).size();
int today = db.getTodayReminders().size();
// Publish the extension data update.
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.drawable.ic_stat_notification_icon)
.status(String.valueOf(notes))
.expandedTitle(
notes + " " + getString(R.string.notes).toLowerCase())
.expandedBody(
remindersNotExpired + " "
+ getString(R.string.reminders) + ", "
+ (remindersTotal - remindersNotExpired) + " "
+ getString(R.string.expired)
+ System.getProperty("line.separator") + today
+ " " + getString(R.string.today))
.clickIntent(new Intent(this, MainActivity.class)));
}
示例9: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
String nextAlarm = Settings.System.getString(getContentResolver(),
Settings.System.NEXT_ALARM_FORMATTED);
Matcher m = sDigitPattern.matcher(nextAlarm);
if (m.find() && m.start() > 0) {
nextAlarm = nextAlarm.substring(0, m.start()) + "\n" + nextAlarm.substring(m.start());
}
publishUpdate(new ExtensionData()
.visible(!TextUtils.isEmpty(nextAlarm))
.icon(R.drawable.ic_extension_next_alarm)
.status(nextAlarm)
.expandedBody(getString(R.string.next_alarm))
.clickIntent(new Intent(Intent.ACTION_MAIN)
.setPackage("com.google.android.deskclock")
.addCategory(Intent.CATEGORY_LAUNCHER)));
}
示例10: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
Cursor cursor = openMissedCallsCursor();
int missedCalls = 0;
StringBuilder names = new StringBuilder();
while (cursor.moveToNext()) {
++missedCalls;
if (names.length() > 0) {
names.append(", ");
}
names.append(cursor.getString(MissedCallsQuery.CACHED_NAME));
}
cursor.close();
publishUpdate(new ExtensionData()
.visible(missedCalls > 0)
.icon(R.drawable.ic_extension_missed_calls)
.status(Integer.toString(missedCalls))
.expandedTitle(
getResources().getQuantityString(
R.plurals.missed_calls_title_template, missedCalls, missedCalls))
.expandedBody(getString(R.string.missed_calls_body_template, names.toString()))
.clickIntent(new Intent(Intent.ACTION_VIEW, CallLog.Calls.CONTENT_URI)));
}
示例11: handleMessage
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
/**
* Handler method that that acts an and expiration checker that upon expiry simple hides the
* dashclock notification.
*/
@Override
public void handleMessage(Message msgMessage) {
try {
Log.d(getTag(), "User has been notified of logoff so hide message");
ExtensionData edtInformation = new ExtensionData();
edtInformation.visible(false);
doUpdate(edtInformation);
} catch (Exception e) {
Log.e(ComputerWidget.this.getTag(), "Error hiding the notification", e);
}
}
示例12: onStartCommand
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
String title = intent.getStringExtra(DASH_TITLE);
String body = intent.getStringExtra(DASH_BODY);
try {
publishUpdate(new ExtensionData().visible(true)
.icon(R.drawable.ic_extension).status(title).expandedTitle(title)
.expandedBody(body)
.clickIntent(new Intent(this, ProxyActivity.class)));
}
catch (Exception exp) {
// This can happen if the UpdateService is running, Dashclock is
// installed, but the widget is not added to Dashclock.
}
return START_NOT_STICKY;
}
示例13: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int i) {
final String ownerInfo = preferences.getString(Constants.PREFS_OWNER_INFO_KEY,
getString(R.string.default_widget_text));
final String ownerEmail = preferences.getString(Constants.PREFS_OWNER_EMAIL_KEY,
getString(R.string.default_email));
// Publish the extension data update.
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.drawable.app_icon_widget)
.status(ownerEmail)
.expandedTitle(getString(R.string.app_name_short))
.expandedBody(ownerInfo)
);
}
示例14: onUpdateData
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
@Override
protected void onUpdateData(int reason) {
Integer index = wheel.nextInt(quotes.length);
Intent expand = new Intent();
expand.setClassName(this, "net.logomancy.dashquotes.civ5.ExpandActivity");
expand.putExtra("net.logomancy.dashquotes.civ5.QuoteString", quotes[index]);
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.mipmap.ic_launcher)
.status(res.getString(R.string.sys_short_title))
.expandedTitle(res.getString(R.string.app_name))
.expandedBody(quotes[index])
.clickIntent(expand));
}
示例15: updateInfo
import com.google.android.apps.dashclock.api.ExtensionData; //导入依赖的package包/类
private void updateInfo() {
if(dump == null) {
publishUpdate(null);
return;
}
Context context = DobroApplication.getApplicationStatic();
Intent notificationIntent = new Intent(context,
DobroStarredEditor.class);
notificationIntent.putExtra(GDActivity.GD_ACTION_BAR_TITLE,
context.getString(R.string.starred));
notificationIntent.putExtra(DobroConstants.FAVS_DUMP, dump);
publishUpdate(new ExtensionData()
.visible(true)
.icon(R.drawable.dashclock)
.status("+")
.expandedTitle("DobroReader")
.expandedBody("Новые сообщения:\n"+text)
.clickIntent(notificationIntent));
}