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


Java Updatable类代码示例

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


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

示例1: run

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void run() {
    long c = get();

    Updatable u = actual;

    for (;;) {
        long d = coalesce ? 1 : c;
        for (long i = 0; i < d; i++) {
            if (cancelled) {
                return;
            }

            u.update();
        }

        c = addAndGet(-c);
        if (c == 0L) {
            break;
        }
    }
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:23,代码来源:AgeraObserveOnExecutor.java

示例2: addUpdatable

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void addUpdatable(@NonNull Updatable updatable) {
    UpdatableAsSubscriber s;
    synchronized (this) {
        if (updatables == null) {
            throw new IllegalStateException("The source Rx Observable has terminated");
        }

        if (updatables.containsKey(updatable)) {
            throw new IllegalStateException("The Updatable is already added");
        }

        s = new UpdatableAsSubscriber(updatable);
        updatables.put(updatable, s);
    }
    source.unsafeSubscribe(s);
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:18,代码来源:RxObservableAsAgera.java

示例3: onLoadData

import com.google.android.agera.Updatable; //导入依赖的package包/类
protected void onLoadData() {
    final MessageStore store = MessageStore.messagesStore(getApplicationContext());
    messagesRepository = store.getSimpleMessagesRepository();
    // TODO: 16/8/9 double notify!
    dataUpdatable = new Updatable() {
        @Override public void update() {
            messages.addAll(messagesRepository.get());
            presenter.notifyDataSetChanged();
            // Maybe we have another graceful way
            messagesRepository.removeUpdatable(dataUpdatable);
            dataUpdatable = null;
        }
    };
    messagesRepository.addUpdatable(dataUpdatable);
    messageFactory = new MessageFactory.Builder()
        .setFromUserId(TimeKey.userId)
        .setToUserId(provideServiceId())
        .build();
    MessageFactory messageFactory4Service = new MessageFactory.Builder()
        .setFromUserId(provideServiceId())
        .setToUserId(TimeKey.userId)
        .build();
    TextContent welcome = new TextContent("Can I help you?");
    messages.add(messageFactory4Service.newMessage(welcome));
}
 
开发者ID:drakeet,项目名称:TimeMachine,代码行数:26,代码来源:DrawerActivity.java

示例4: onAdd

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
protected void onAdd(@NonNull Updatable updatable, @NonNull Updatable wrapper) {
    for (int i = 0; i < count; i++) {
        if (isListening(updatable)) {
            updatable.update();
        }
    }
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:9,代码来源:AgeraRange.java

示例5: initData

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override protected void initData() {
    SaveVolley saveVolley = SaveVolleys
        .<GankData>request(TEST_URL)
        .method(Method.GET)
        .parseStyle(FASTJSON)
        .classOf(GankData.class)
        .createRequest()
        .context(this)
        .compile();

    final Repository<GankResultData> repository = Repositories
        .repositoryWithInitialValue(INITIAL_VALUE)
        .observe(saveVolley.getReservoir())
        .onUpdatesPerLoop()
        .goTo(executor)
        .attemptGetFrom(saveVolley.getReservoir())
        .orSkip()
        .thenAttemptTransform(new Function<Object, Result<GankResultData>>() {
            /**
             * Returns the result of applying this function to {@code input}.
             */
            @NonNull @Override public Result<GankResultData> apply(@NonNull Object input) {
                if (input instanceof GankData) {
                    return Result.success(((GankData) input).results.get(0));
                } else if (input instanceof VolleyError) {
                    return Result.failure((VolleyError) input);
                }
                return Result.failure();
            }
        })
        .orSkip()
        .compile();

    repository.addUpdatable(new Updatable() {
        @Override public void update() {
            getContentText.setText(repository.get().toString());
        }
    });
}
 
开发者ID:CaMnter,项目名称:SaveVolley,代码行数:40,代码来源:Okhttp3AgeraFastjsonActivity.java

示例6: initData

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override protected void initData() {
    SaveVolley saveVolley = SaveVolleys
        .<GankData>request(TEST_URL)
        .method(Method.GET)
        .parseStyle(GSON)
        .classOf(GankData.class)
        .createRequest()
        .context(this)
        .compile();

    final Repository<GankResultData> repository = Repositories.repositoryWithInitialValue(
        INITIAL_VALUE)
        .observe(saveVolley.getReservoir())
        .onUpdatesPerLoop()
        .goTo(executor)
        .attemptGetFrom(saveVolley.getReservoir())
        .orSkip()
        .thenAttemptTransform(new Function<Object, Result<GankResultData>>() {
            /**
             * Returns the result of applying this function to {@code input}.
             */
            @NonNull @Override public Result<GankResultData> apply(@NonNull Object input) {
                if (input instanceof GankData) {
                    return Result.success(((GankData) input).results.get(0));
                } else if (input instanceof VolleyError) {
                    return Result.failure((VolleyError) input);
                }
                return Result.failure();
            }
        })
        .orSkip()
        .compile();

    repository.addUpdatable(new Updatable() {
        @Override public void update() {
            getContentText.setText(repository.get().toString());
        }
    });
}
 
开发者ID:CaMnter,项目名称:SaveVolley,代码行数:40,代码来源:Okhttp3AgeraGsonActivity.java

示例7: addUpdatable

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public final void addUpdatable(@NonNull Updatable updatable) {
    U wrapper = createWrapper(updatable);
    if (map.putIfAbsent(updatable, wrapper) != null) {
        throw new IllegalStateException("The updatable instance has been already added");
    }
    onAdd(updatable, wrapper);
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:9,代码来源:AgeraTracking.java

示例8: removeUpdatable

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public final void removeUpdatable(@NonNull Updatable updatable) {
    U wrapper = map.remove(updatable);
    if (wrapper == null) {
        throw new IllegalStateException("The updatable is (no longer) registered with this Observable");
    }
    onRemove(updatable, wrapper);
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:9,代码来源:AgeraTracking.java

示例9: initData

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override protected void initData() {
    SaveVolley saveVolley = SaveVolleys
        .<GankData>request(TEST_URL)
        .method(Method.GET)
        .parseStyle(GSON)
        .classOf(GankData.class)
        .createRequest()
        .context(this)
        .compile();

    final Repository<GankResultData> repository = Repositories
        .repositoryWithInitialValue(INITIAL_VALUE)
        .observe(saveVolley.getReservoir())
        .onUpdatesPerLoop()
        .goTo(executor)
        .attemptGetFrom(saveVolley.getReservoir())
        .orSkip()
        .thenAttemptTransform(new Function<Object, Result<GankResultData>>() {
            /**
             * Returns the result of applying this function to {@code input}.
             */
            @NonNull @Override public Result<GankResultData> apply(@NonNull Object input) {
                if (input instanceof GankData) {
                    return Result.success(((GankData) input).results.get(0));
                } else if (input instanceof VolleyError) {
                    return Result.failure((VolleyError) input);
                }
                return Result.failure();
            }
        })
        .orSkip()
        .compile();

    repository.addUpdatable(new Updatable() {
        @Override public void update() {
            getContentText.setText(repository.get().toString());
        }
    });
}
 
开发者ID:CaMnter,项目名称:SaveVolley,代码行数:40,代码来源:HurlAgeraGsonActivity.java

示例10: TakeUntilUpdatable

import com.google.android.agera.Updatable; //导入依赖的package包/类
TakeUntilUpdatable(Updatable actual, AgeraTakeUntil parent, Observable other) {
    this.actual = actual;
    this.parent = parent;
    this.other = other;
    this.otherUpdatable = new Updatable() {
        @Override
        public void update() {
            updateOther();
        }
    };
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:12,代码来源:AgeraTakeUntil.java

示例11: onAdd

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
protected void onAdd(@NonNull final Updatable updatable, @NonNull Trampoline wrapper) {
    wrapper.offer(new Runnable() {
        @Override
        public void run() {
            source.addUpdatable(updatable);
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:10,代码来源:AgeraSubscribeOnExecutor.java

示例12: onRemove

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
protected void onRemove(@NonNull final Updatable updatable, @NonNull Trampoline wrapper) {
    wrapper.offer(new Runnable() {
        @Override
        public void run() {
            source.removeUpdatable(updatable);
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:10,代码来源:AgeraSubscribeOnExecutor.java

示例13: addUpdatable

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void addUpdatable(@NonNull final Updatable updatable) {
    handler.post(new Runnable() {
        @Override
        public void run() {
            source.addUpdatable(updatable);
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:10,代码来源:AgeraSubscribeOnLooper.java

示例14: removeUpdatable

import com.google.android.agera.Updatable; //导入依赖的package包/类
@Override
public void removeUpdatable(@NonNull final Updatable updatable) {
    handler.post(new Runnable() {
        @Override
        public void run() {
            source.removeUpdatable(updatable);
        }
    });
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:10,代码来源:AgeraSubscribeOnLooper.java

示例15: createWrapper

import com.google.android.agera.Updatable; //导入依赖的package包/类
@NonNull
@Override
protected FlatMapUpdatable createWrapper(@NonNull Updatable updatable) {
    Supplier<Observable> supplier = new Supplier<Observable>() {
        int i;
        @NonNull
        @Override
        public Observable get() {
            return sources[i++];
        }
    };
    return new FlatMapUpdatable(updatable, supplier);
}
 
开发者ID:akarnokd,项目名称:RxAgera,代码行数:14,代码来源:AgeraMerge.java


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