当前位置: 首页>>代码示例>>Java>>正文


Java SunshineSyncAdapter类代码示例

本文整理汇总了Java中com.example.android.sunshine.app.sync.SunshineSyncAdapter的典型用法代码示例。如果您正苦于以下问题:Java SunshineSyncAdapter类的具体用法?Java SunshineSyncAdapter怎么用?Java SunshineSyncAdapter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SunshineSyncAdapter类属于com.example.android.sunshine.app.sync包,在下文中一共展示了SunshineSyncAdapter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateEmptyView

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
private void updateEmptyView() {
    if ( mForecastAdapter.getItemCount() == 0 ) {
        TextView tv = (TextView) getView().findViewById(R.id.recyclerview_forecast_empty);
        if ( null != tv ) {
            // if cursor is empty, why? do we have an invalid location
            int message = R.string.empty_forecast_list;
            @SunshineSyncAdapter.LocationStatus int location = Utility.getLocationStatus(getActivity());
            switch (location) {
                case SunshineSyncAdapter.LOCATION_STATUS_SERVER_DOWN:
                    message = R.string.empty_forecast_list_server_down;
                    break;
                case SunshineSyncAdapter.LOCATION_STATUS_SERVER_INVALID:
                    message = R.string.empty_forecast_list_server_error;
                    break;
                case SunshineSyncAdapter.LOCATION_STATUS_INVALID:
                    message = R.string.empty_forecast_list_invalid_location;
                    break;
                default:
                    if (!Utility.isNetworkAvailable(getActivity())) {
                        message = R.string.empty_forecast_list_no_network;
                    }
            }
            tv.setText(message);
        }
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:27,代码来源:ForecastFragment.java

示例2: onSharedPreferenceChanged

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if ( key.equals(getString(R.string.pref_location_key)) ) {
        // we've changed the location
        // first clear locationStatus
        Utility.resetLocationStatus(this);
        SunshineSyncAdapter.syncImmediately(this);
    } else if ( key.equals(getString(R.string.pref_units_key)) ) {
        // units have changed. update lists of weather entries accordingly
        getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    } else if ( key.equals(getString(R.string.pref_location_status_key)) ) {
        // our location status has changed.  Update the summary accordingly
        Preference locationPreference = findPreference(getString(R.string.pref_location_key));
        bindPreferenceSummaryToValue(locationPreference);
    } else if ( key.equals(getString(R.string.pref_art_pack_key)) ) {
        // art pack have changed. update lists of weather entries accordingly
        getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
}
 
开发者ID:Hitesh880443,项目名称:SunshineWithWear,代码行数:20,代码来源:SettingsActivity.java

示例3: onDataChanged

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
@Override
public void onDataChanged(DataEventBuffer dataEvents) {
    Log.d(LOG_TAG, "onDataChanged" );
    for (DataEvent dataEvent : dataEvents) {
        if (DataEvent.TYPE_CHANGED == dataEvent.getType()) {
            DataItem dataItem = dataEvent.getDataItem();
            DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();

            String path = dataEvent.getDataItem().getUri().getPath();
            if (path.equals(WEATHER_PATH)) {
                Log.d(LOG_TAG, "/weather id=" + dataMap.getString(KEY_UUID));
                SunshineSyncAdapter.syncImmediately(this);
            }
        }
    }
}
 
开发者ID:jenniferlimtan,项目名称:UdacityProject6,代码行数:17,代码来源:WatchFaceService.java

示例4: getLocationStatus

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
/**
 *
 * @param c Context used to get the SharedPreferences
 * @return the location status integer type
 */
@SuppressWarnings("ResourceType")
static public @SunshineSyncAdapter.LocationStatus
int getLocationStatus(Context c){
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c);
    return sp.getInt(c.getString(R.string.pref_location_status_key), SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN);
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:12,代码来源:Utility.java

示例5: resetLocationStatus

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
/**
 * Resets the location status.  (Sets it to SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN)
 * @param c Context used to get the SharedPreferences
 */
static public void resetLocationStatus(Context c){
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(c);
    SharedPreferences.Editor spe = sp.edit();
    spe.putInt(c.getString(R.string.pref_location_status_key), SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN);
    spe.apply();
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:11,代码来源:Utility.java

示例6: setPreferenceSummary

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
private void setPreferenceSummary(Preference preference, Object value) {
    String stringValue = value.toString();
    String key = preference.getKey();

    if (preference instanceof ListPreference) {
        // For list preferences, look up the correct display value in
        // the preference's 'entries' list (since they have separate labels/values).
        ListPreference listPreference = (ListPreference) preference;
        int prefIndex = listPreference.findIndexOfValue(stringValue);
        if (prefIndex >= 0) {
            preference.setSummary(listPreference.getEntries()[prefIndex]);
        }
    } else if (key.equals(getString(R.string.pref_location_key))) {
        @SunshineSyncAdapter.LocationStatus int status = Utility.getLocationStatus(this);
        switch (status) {
            case SunshineSyncAdapter.LOCATION_STATUS_OK:
                preference.setSummary(stringValue);
                break;
            case SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN:
                preference.setSummary(getString(R.string.pref_location_unknown_description, value.toString()));
                break;
            case SunshineSyncAdapter.LOCATION_STATUS_INVALID:
                preference.setSummary(getString(R.string.pref_location_error_description, value.toString()));
                break;
            default:
                // Note --- if the server is down we still assume the value
                // is valid
                preference.setSummary(stringValue);
        }
    } else {
        // For other preferences, set the summary to the value's simple string representation.
        preference.setSummary(stringValue);
    }

}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:36,代码来源:SettingsActivity.java

示例7: onSharedPreferenceChanged

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if ( key.equals(getString(R.string.pref_location_key)) ) {
        // we've changed the location
        // Wipe out any potential PlacePicker latlng values so that we can use this text entry.
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.remove(getString(R.string.pref_location_latitude));
        editor.remove(getString(R.string.pref_location_longitude));
        editor.commit();

        // Remove attributions for our any PlacePicker locations.
        if (mAttribution != null) {
            mAttribution.setVisibility(View.GONE);
        }

        Utility.resetLocationStatus(this);
        SunshineSyncAdapter.syncImmediately(this);
    } else if ( key.equals(getString(R.string.pref_units_key)) ) {
        // units have changed. update lists of weather entries accordingly
        getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    } else if ( key.equals(getString(R.string.pref_location_status_key)) ) {
        // our location status has changed.  Update the summary accordingly
        Preference locationPreference = findPreference(getString(R.string.pref_location_key));
        bindPreferenceSummaryToValue(locationPreference);
    } else if ( key.equals(getString(R.string.pref_art_pack_key)) ) {
        // art pack have changed. update lists of weather entries accordingly
        getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:30,代码来源:SettingsActivity.java

示例8: onReceive

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
@Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
    super.onReceive(context, intent);
    if (SunshineSyncAdapter.ACTION_DATA_UPDATED.equals(intent.getAction())) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(
                new ComponentName(context, getClass()));
        appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:11,代码来源:DetailWidgetProvider.java

示例9: onReceive

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
@Override
public void onReceive(@NonNull Context context, @NonNull Intent intent) {
    super.onReceive(context, intent);
    if (SunshineSyncAdapter.ACTION_DATA_UPDATED.equals(intent.getAction())) {
        context.startService(new Intent(context, TodayWidgetIntentService.class));
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:8,代码来源:TodayWidgetProvider.java

示例10: onHandleIntent

import com.example.android.sunshine.app.sync.SunshineSyncAdapter; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    super.onHandleIntent(intent);
    boolean dataUpdated = intent != null &&
            SunshineSyncAdapter.ACTION_DATA_UPDATED.equals(intent.getAction());
    if (dataUpdated && isEnabled()) {
        onUpdate(UPDATE_REASON_OTHER);
    }
}
 
开发者ID:changja88,项目名称:Udacity_Sunshine,代码行数:10,代码来源:WeatherMuzeiSource.java


注:本文中的com.example.android.sunshine.app.sync.SunshineSyncAdapter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。