Best code examples for Java 8 Observable class (java.util.Observable)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Observable class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 Observable examples from Open Source projects
This code example shows how to use the following methods: getRows, getValues, addObserver
                        new String[] {
                            Settings.System.NAME,
                            Settings.System.VALUE,
                        }, null, null, null); 
 
                final ContentQueryMap cqm = new ContentQueryMap(
                        cursor, Settings.System.NAME, true, null);
                // Get the current state of the CQM. This forces a requery and means that the 
                // call to getValues() below won't do a requery(). 
                cqm.getRows();
                 
                // The cache won't notice changes until the loop runs. 
                Settings.System.putString(r, "test", "New Value");
                ContentValues v = cqm.getValues("test");
                String value = v.getAsString(Settings.System.VALUE);
                assertEquals("Value", value);
 
                // Use an Observer to find out when the cache does update. 
                cqm.addObserver(new Observer() {
                    public void update(Observable o, Object arg) {

6
CodeRank
This code example shows how to use the following methods: deleteObserver
 
    @Override 
    public void onStop() { 
        super.onStop(); 
        if (mSettingsObserver != null) {
            mContentQueryMap.deleteObserver(mSettingsObserver);
        } 
    } 
 
    private PreferenceScreen createPreferenceHierarchy() {
        PreferenceScreen root = getPreferenceScreen();
        if (root != null) {
            root.removeAll();
        } 
        addPreferencesFromResource(R.xml.location_settings); 
        root = getPreferenceScreen();
 
        mNetwork = (CheckBoxPreference) root.findPreference(KEY_LOCATION_NETWORK);
        mGps = (CheckBoxPreference) root.findPreference(KEY_LOCATION_GPS);
        mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS);
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: notifyObservers
	} 
	 
	public synchronized void detectChanges() { 
		int latestRevision = getLatestRevision();
		if (lastRevision != latestRevision)
			hiveStatus.notifyObservers();
		lastRevision = latestRevision;
	} 
 
	public void run() { 
		while (true) { 
			try { 
				detectChanges(); 
				lastRun = System.currentTimeMillis();
			} catch (Exception e) {}
 
			try { 
				sleep(getConfiguredSleepPeriodMs());
			} catch (InterruptedException e) {}
		} 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: addObserver
    private float minTemp = 200;
    private float tempSum = 0.0f;
    private int numReadings;
 
    public StatisticsDisplay(Observable observable) {
        observable.addObserver(this);
    } 
 
    public void update(Observable observable, Object arg) {
        if (observable instanceof WeatherData) {
            WeatherData weatherData = (WeatherData) observable;
            float temp = weatherData.getTemperature();
            tempSum += temp;
            numReadings++;
 
            if (temp > maxTemp) {
                maxTemp = temp;
            } 
 
            if (temp < minTemp) {
Full Snippet Info
4
CodeRank
This code example shows how to use the following methods: addObserver
	private float minTemp = 200;
	private float tempSum= 0.0f;
	private int numReadings;
 
	public StatisticsDisplay(Observable observable) {
		observable.addObserver(this);
	} 
 
	public void update(Observable observable, Object arg) {
		if (observable instanceof WeatherData) {
			WeatherData weatherData = (WeatherData)observable;
			float temp = weatherData.getTemperature();
			tempSum += temp;
			numReadings++;
 
			if (temp > maxTemp) {
				maxTemp = temp;
			} 
  
			if (temp < minTemp) {
Full Snippet Info
4
CodeRank
Related Java 8 Observable Questions & Answers:
See Code Examples for Java 8 Observable Methods: