本文整理汇总了Java中org.hisp.dhis.client.sdk.android.api.D2类的典型用法代码示例。如果您正苦于以下问题:Java D2类的具体用法?Java D2怎么用?Java D2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
D2类属于org.hisp.dhis.client.sdk.android.api包,在下文中一共展示了D2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
AppSettingsBuilder.getInstance().init(getApplicationContext());
PreferencesState.getInstance().init(getApplicationContext());
LocationMemory.getInstance().init(getApplicationContext());
TypefaceCache.getInstance().init(getApplicationContext());
AutoTabLayoutUtils.init();
D2.init(this);
FlowConfig flowConfig = new FlowConfig
.Builder(this)
.addDatabaseHolder(EyeSeeTeaGeneratedDatabaseHolder.class)
.build();
FlowManager.init(flowConfig);
// Create indexes to accelerate the DB selects and avoid SQlite errors
createDBIndexes();
}
示例2: logout
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Override
public void logout(final IDataSourceCallback<Void> callback) {
D2.me().signOut()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean result) {
callback.onSuccess(null);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
callback.onError(throwable);
}
});
}
示例3: logout
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Override
public void logout(final IDataSourceCallback<Void> callback) {
if (D2.isConfigured()) {
D2.me().signOut()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean result) {
callback.onSuccess(null);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
callback.onError(throwable);
}
});
} else {
//The user is never logged
callback.onSuccess(null);
}
}
示例4: getCategoryOptionUIDByCurrentUser
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
public static String getCategoryOptionUIDByCurrentUser() {
String userName =
D2.me().userCredentials().toBlocking().single().getUsername().toLowerCase();
List<CategoryOption> categoryOptions =
D2.categoryOptions().list().toBlocking().single();
for (CategoryOption categoryOption : categoryOptions) {
if (categoryOption.getCode() != null
&& categoryOption.getCode().toLowerCase().equals(
userName)) {
return categoryOption.getUId();
}
}
return null;
}
示例5: pullEvents
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
private void pullEvents(PullFilters filters, IPullSourceCallback callback) {
Scheduler listThread = Schedulers.newThread();
List<Program> sdkPrograms = D2.me().programs().list().subscribeOn(listThread)
.observeOn(listThread).toBlocking().single();
List<OrganisationUnit> sdkOrganisationUnits =
D2.me().organisationUnits().list().subscribeOn(listThread)
.observeOn(listThread).toBlocking().single();
if (!PullController.PULL_IS_ACTIVE) return;
for (Program program : sdkPrograms) {
for (OrganisationUnit organisationUnit : sdkOrganisationUnits) {
for (Program orgunitProgram : organisationUnit.getPrograms()) {
if (orgunitProgram.getUId().equals(program.getUId())) {
if (!PullController.PULL_IS_ACTIVE) return;
EventFilters eventFilters = new EventFilters();
eventFilters.setProgramUId(program.getUId());
eventFilters.setOrganisationUnitUId(organisationUnit.getUId());
eventFilters.setStartDate(filters.getStartDate());
eventFilters.setEndDate(filters.getEndDate());
eventFilters.setMaxEvents(filters.getMaxEvents());
Scheduler pullEventsThread = Schedulers.newThread();
D2.events().pull(eventFilters)
.subscribeOn(pullEventsThread)
.observeOn(pullEventsThread).toBlocking().single();
}
}
}
}
}
示例6: pushEvents
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
private void pushEvents(final IDataSourceCallback<Map<String, PushReport>> callback) {
final Set<String> eventUids = getEventUidToBePushed();
if(eventUids.isEmpty() || eventUids.size()==0){
callback.onError(new SurveysToPushNotFoundException("Null events"));
return;
}
Observable<Map<String, ImportSummary>> eventObserver =
D2.events().push(eventUids);
eventObserver
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Map<String, ImportSummary>>() {
@Override
public void call(Map<String, ImportSummary> mapEventsImportSummary) {
if(mapEventsImportSummary==null){
callback.onError(new PushReportException("Error during push"));
return;
}
Log.d(TAG,
"Push of events finish. Number of events: "
+ mapEventsImportSummary.size());
try {
callback.onSuccess(PushReportMapper.mapFromImportSummariesToPushReports(mapEventsImportSummary));
}catch (NullPointerException e){
callback.onError(new PushReportException(e));
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
callback.onError(new PushDhisException(throwable));
}
});
}
示例7: pullMetada
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
public void pullMetada(final PullFilters pullFilters, final Callback callback) {
if (cancelPull) {
callback.onCancel();
return;
}
if(pullFilters.pullMetaData()) {
mPullRemoteDataSource.pullMetadata(
new IDataSourceCallback<List<OrganisationUnit>>() {
@Override
public void onSuccess(List<OrganisationUnit> organisationUnits) {
if (!pullFilters.downloadData() || pullFilters.pullDataAfterMetadata()) {
convertMetaData(callback);
callback.onComplete();
} else {
convertMetaData(callback);
pullData(pullFilters, organisationUnits, callback);
}
}
@Override
public void onError(Throwable throwable) {
callback.onError(throwable);
}
});
}
else {
if (pullFilters.downloadData()) {
List<OrganisationUnit> organisationUnitsList = D2.me().organisationUnits().list().toBlocking().first();
pullData(pullFilters, organisationUnitsList, callback);
}
else{
callback.onComplete();
}
}
}
示例8: pullData
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
public void pullData(PullFilters pullFilters, List<OrganisationUnit> organisationUnits,
IDataSourceCallback<List<Event>> callback) {
boolean isNetworkAvailable = isNetworkAvailable();
if (!isNetworkAvailable) {
callback.onError(new NetworkException());
} else {
List<Event> events = new ArrayList<>();
for (OrganisationUnit organisationUnit : organisationUnits) {
if(pullFilters.getDataByOrgUnit() != null && !pullFilters.getDataByOrgUnit().equals("")){
if(!pullFilters.getDataByOrgUnit().equals(organisationUnit.getName())){
continue;
}
}
Scheduler pullEventsThread = Schedulers.newThread();
EventFilters eventFilters = new EventFilters();
eventFilters.setStartDate(pullFilters.getStartDate());
eventFilters.setEndDate(pullFilters.getEndDate());
eventFilters.setMaxEvents(pullFilters.getMaxEvents());
eventFilters.setOrganisationUnitUId(organisationUnit.getUId());
mPullDhisSDKDataSourceStrategy.setEventFilters(eventFilters);
List<Event> eventsByOrgUnit = D2.events().pull(eventFilters)
.subscribeOn(pullEventsThread)
.observeOn(pullEventsThread)
.toBlocking()
.single();
events.addAll(eventsByOrgUnit);
}
callback.onSuccess(events);
}
}
示例9: pushEvents
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
private void pushEvents(final IDataSourceCallback<Map<String, PushReport>> callback) {
final Set<String> eventUids = getEventUidToBePushed();
if (eventUids.isEmpty() || eventUids.size() == 0) {
callback.onError(new ConvertedEventsToPushNotFoundException());
return;
}
Observable<Map<String, ImportSummary>> eventObserver =
D2.events().push(eventUids);
eventObserver
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.subscribe(new Action1<Map<String, ImportSummary>>() {
@Override
public void call(Map<String, ImportSummary> mapEventsImportSummary) {
if (mapEventsImportSummary == null) {
callback.onError(new PushReportException("Error during push"));
return;
}
Log.d(TAG,
"Push of events finish. Number of events: "
+ mapEventsImportSummary.size());
try {
callback.onSuccess(
PushReportMapper.mapFromImportSummariesToPushReports(
mapEventsImportSummary));
} catch (NullPointerException e) {
callback.onError(new PushReportException(e));
}
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
callback.onError(new PushDhisException(throwable));
}
});
}
示例10: UserModule
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的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();
}
}
示例11: providesCurrentUserInteractor
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Provides
@Nullable
@PerUser
@Override
public CurrentUserInteractor providesCurrentUserInteractor() {
if (D2.isConfigured()) {
return D2.me();
}
return null;
}
示例12: providesUserOrganisationUnitInteractor
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Provides
@Nullable
@PerUser
public UserOrganisationUnitInteractor providesUserOrganisationUnitInteractor() {
if (D2.isConfigured()) {
return D2.me().organisationUnits();
}
return null;
}
示例13: providesUserProgramInteractor
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Provides
@Nullable
@PerUser
public UserProgramInteractor providesUserProgramInteractor() {
if (D2.isConfigured()) {
return D2.me().programs();
}
return null;
}
示例14: providesProgramStageInteractor
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Provides
@Nullable
@PerUser
public ProgramStageInteractor providesProgramStageInteractor() {
if (D2.isConfigured()) {
return D2.programStages();
}
return null;
}
示例15: providesProgramStageSectionInteractor
import org.hisp.dhis.client.sdk.android.api.D2; //导入依赖的package包/类
@Provides
@Nullable
@PerUser
public ProgramStageSectionInteractor providesProgramStageSectionInteractor() {
if (D2.isConfigured()) {
return D2.programStageSections();
}
return null;
}