package com.github.hunter0x7c7.sync.model.data; import com.github.hunter0x7c7.sync.model.bean.PhotoBean; import com.github.hunter0x7c7.sync.model.data.result.ResultEntity; import com.github.hunter0x7c7.sync.model.data.source.CacheDataSource; import com.github.hunter0x7c7.sync.model.data.source.HttpDataSource; import com.github.hunter0x7c7.sync.model.data.source.LocalDataSource; import io.reactivex.Observable; import lombok.NonNull; /** * ================================================================ *

* 版 权: Hunter(c)2020 *

* 作 者: Hunter *

* 版 本: V1.0 *

* 创建日期: 2020/8/12 10:48 *

* 描 述: *

*

* 修订历史: *

* ================================================================ */ public class MainRepository implements HttpDataSource, LocalDataSource, CacheDataSource { private volatile static MainRepository sInstance = null; private final HttpDataSource mHttpDataSource; private final LocalDataSource mLocalDataSource; private final CacheDataSource mCacheDataSource; private MainRepository(@NonNull HttpDataSource http, @NonNull LocalDataSource local, @NonNull CacheDataSource cache) { this.mHttpDataSource = http; this.mLocalDataSource = local; this.mCacheDataSource = cache; } public static MainRepository getInstance(@NonNull HttpDataSource http, @NonNull LocalDataSource local, @NonNull CacheDataSource cache) { if (sInstance == null) { synchronized (MainRepository.class) { if (sInstance == null) { sInstance = new MainRepository(http, local, cache); } } } return sInstance; } @Override public String getCacheHost() { return mCacheDataSource.getCacheHost(); } @Override public void cacheHost(String host) { mCacheDataSource.cacheHost(host); } @Override public String getCacheUsername() { return mCacheDataSource.getCacheUsername(); } @Override public String getCacheNickname() { return mCacheDataSource.getCacheNickname(); } @Override public int getUid() { return mCacheDataSource.getUid(); } @Override public String getEncryptPassword() { return null; } @Override public String getEncryptPassword(String password) { return mCacheDataSource.getEncryptPassword(password); } @Override public int getVersionCode() { return mCacheDataSource.getVersionCode(); } @Override public boolean isOldSystem() { return mCacheDataSource.isOldSystem(); } @Override public void setOldSystem(boolean isOld) { mCacheDataSource.setOldSystem(isOld); } @Override public void clearCacheUserInfo() { mCacheDataSource.clearCacheUserInfo(); } @Override public int getAgreePrivacyPolicy() { return 0; } @Override public void setAgreePrivacyPolicy(int verCode) { } @Override public int getGuideVersionCode() { return 0; } @Override public void setGuideVersionCode(int verCode) { } @Override public String getLocalHost() { return null; } @Override public void saveHost(String host) { } @Override public Observable> getImageList(String mode, int index, int size, String key) { return mHttpDataSource.getImageList(mode, index, size, key); } }