本文整理汇总了Java中android.support.wearable.complications.ProviderUpdateRequester类的典型用法代码示例。如果您正苦于以下问题:Java ProviderUpdateRequester类的具体用法?Java ProviderUpdateRequester怎么用?Java ProviderUpdateRequester使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProviderUpdateRequester类属于android.support.wearable.complications包,在下文中一共展示了ProviderUpdateRequester类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
ComponentName provider = extras.getParcelable(EXTRA_PROVIDER_COMPONENT);
int complicationId = extras.getInt(EXTRA_COMPLICATION_ID);
String preferenceKey = getPreferenceKey(provider, complicationId);
SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, 0);
int value = pref.getInt(preferenceKey, 0);
SharedPreferences.Editor editor = pref.edit();
editor.putInt(preferenceKey, value + 1); // Increase value by 1
editor.apply();
// Request an update for the complication that has just been toggled.
ProviderUpdateRequester requester = new ProviderUpdateRequester(context, provider);
requester.requestUpdate(complicationId);
}
开发者ID:googlesamples,项目名称:android-WearComplicationProvidersTestSuite,代码行数:18,代码来源:ComplicationToggleReceiver.java
示例2: onReceive
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final Bundle extras = intent.getExtras();
final ComponentName provider = extras.getParcelable(EXTRA_PROVIDER_COMPONENT);
int complicationId = extras.getInt(EXTRA_COMPLICATION_ID);
PersistentStore.incrementLong(COMPLICATION_STORE);
if (PersistentStore.getLong(COMPLICATION_STORE) == CustomComplicationProviderService.COMPLICATION_STATE.RESET.getValue()) {
PersistentStore.setLong(COMPLICATION_STORE, 0);
}
// Request an update for the complication that has just been tapped.
ProviderUpdateRequester requester = new ProviderUpdateRequester(context, provider);
requester.requestUpdate(complicationId);
if (!JoH.ratelimit("complication-double-tap", 1)) {
startIntent(KeypadInputActivity.class);
// if we get mre than two states we will need to handle restoring the previous state instead of just incrementing so the complication remains where it was before the double tap
}
}
示例3: onReceive
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
ComponentName provider = extras.getParcelable(EXTRA_PROVIDER_COMPONENT);
int complicationId = extras.getInt(EXTRA_COMPLICATION_ID);
// Retrieve data via SharedPreferences.
String preferenceKey = getPreferenceKey(provider, complicationId);
SharedPreferences sharedPreferences =
context.getSharedPreferences(COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY, 0);
int value = sharedPreferences.getInt(preferenceKey, 0);
// Update data for complication.
value = (value + 1) % MAX_NUMBER;
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt(preferenceKey, value);
editor.apply();
// Request an update for the complication that has just been tapped.
ProviderUpdateRequester requester = new ProviderUpdateRequester(context, provider);
requester.requestUpdate(complicationId);
}
示例4: onReceive
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
ComponentName provider = extras.getParcelable(EXTRA_PROVIDER_COMPONENT);
int complicationId = extras.getInt(EXTRA_COMPLICATION_ID);
String preferenceKey = getPreferenceKey(provider, complicationId);
SharedPreferences sharedPreferences =
context.getSharedPreferences(COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY, 0);
int value = sharedPreferences.getInt(preferenceKey, 0);
// Updates data for complication.
value = (value + 1) % MAX_NUMBER;
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putInt(preferenceKey, value);
editor.apply();
// Request an update for the complication that has just been toggled.
ProviderUpdateRequester requester = new ProviderUpdateRequester(context, provider);
requester.requestUpdate(complicationId);
}
示例5: onStartJob
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
@Override
public boolean onStartJob(JobParameters params) {
ProviderUpdateRequester providerUpdateRequester = new ProviderUpdateRequester(this,
new ComponentName(this, ArtworkComplicationProviderService.class));
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
Set<String> complicationSet = preferences.getStringSet(
ArtworkComplicationProviderService.KEY_COMPLICATION_IDS, new TreeSet<>());
if (!complicationSet.isEmpty()) {
int[] complicationIds = new int[complicationSet.size()];
int index = 0;
for (String complicationId : complicationSet) {
complicationIds[index++] = Integer.parseInt(complicationId);
}
if (BuildConfig.DEBUG) {
Log.d(TAG, "Job running, updating " + complicationSet);
}
providerUpdateRequester.requestUpdate(complicationIds);
}
// Schedule the job again to catch the next update to the artwork
scheduleComplicationUpdateJob(this);
return false;
}
示例6: refresh
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
public static void refresh() {
if (JoH.ratelimit("complication-refresh", 5)) {
final ComponentName componentName = new ComponentName(xdrip.getAppContext(), "com.eveningoutpost.dexdrip.Services.CustomComplicationProviderService");
final ProviderUpdateRequester providerUpdateRequester = new ProviderUpdateRequester(xdrip.getAppContext(), componentName);
providerUpdateRequester.requestUpdateAll();
}
Log.d(TAG, "Complication refresh() called");
}
示例7: requestUpdateComplication
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
static void requestUpdateComplication(Context ctx, int id) {
ProviderUpdateRequester requester = new ProviderUpdateRequester(
ctx, ComponentName.createRelative(
"io.singleton.exchangerates",
".ComplicationService"));
requester.requestUpdate(id);
}
示例8: onHandleWork
import android.support.wearable.complications.ProviderUpdateRequester; //导入依赖的package包/类
@Override
protected void onHandleWork(@NonNull Intent intent) {
new ProviderUpdateRequester(this, new ComponentName(this, BlockvoteProviderService.class))
.requestUpdateAll();
}