本文整理汇总了Java中org.hisp.dhis.client.sdk.core.common.network.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于org.hisp.dhis.client.sdk.core.common.network包,在下文中一共展示了Configuration类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UserModule
import org.hisp.dhis.client.sdk.core.common.network.Configuration; //导入依赖的package包/类
public UserModule(String serverUrl, String authority, String accountType) {
this.authority = authority;
this.accountType = accountType;
if (!isEmpty(serverUrl)) {
// it can throw exception in case if configuration has failed
Configuration configuration = new Configuration(serverUrl);
D2.configure(configuration).toBlocking().first();
}
}
示例2: login
import org.hisp.dhis.client.sdk.core.common.network.Configuration; //导入依赖的package包/类
@Override
public void login(final Credentials credentials,
final IDataSourceCallback<UserAccount> callback) {
boolean isNetworkAvailable = isNetworkAvailable();
if (!isNetworkAvailable) {
callback.onError(new NetworkException());
} else {
Configuration configuration = new Configuration(credentials.getServerURL());
D2.configure(configuration)
.flatMap(
new Func1<Void, Observable<org.hisp.dhis.client.sdk.models.user
.UserAccount>>() {
@Override
public Observable<org.hisp.dhis.client.sdk.models.user.UserAccount>
call(
Void aVoid) {
return D2.me().signIn(credentials.getUsername(),
credentials.getPassword());
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<org.hisp.dhis.client.sdk.models.user.UserAccount>() {
@Override
public void call(
org.hisp.dhis.client.sdk.models.user.UserAccount dhisUserAccount) {
UserAccount userAccount = new UserAccount(credentials.getUsername(),
dhisUserAccount.getUId());
callback.onSuccess(userAccount);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
Throwable throwableResult = mapThrowable(throwable);
callback.onError(throwableResult);
}
});
}
}
示例3: login
import org.hisp.dhis.client.sdk.core.common.network.Configuration; //导入依赖的package包/类
@Override
public void login(final Credentials credentials,
final IDataSourceCallback<UserAccount> callback) {
boolean isNetworkAvailable = isNetworkAvailable();
if (!isNetworkAvailable) {
callback.onError(new NetworkException());
} else {
Configuration configuration = new Configuration(credentials.getServerURL());
D2.configure(configuration)
.flatMap(
new Func1<Void, Observable<org.hisp.dhis.client.sdk.models.user
.UserAccount>>() {
@Override
public Observable<org.hisp.dhis.client.sdk.models.user.UserAccount>
call(
Void aVoid) {
return D2.me().signIn(credentials.getUsername(),
credentials.getPassword());
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<org.hisp.dhis.client.sdk.models.user.UserAccount>() {
@Override
public void call(
org.hisp.dhis.client.sdk.models.user.UserAccount dhisUserAccount) {
UserAccount userAccount = new UserAccount(credentials.getUsername(), dhisUserAccount.getUId(),
credentials.isDemoCredentials());
callback.onSuccess(userAccount);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
Throwable throwableResult = mapThrowable(throwable);
callback.onError(throwableResult);
}
});
}
}