HunterHuang0X7C7
2023-08-12 1c7c28f03215f03e97387d7e6b45ae752c396dcb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
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;
 
/**
 * ================================================================
 * <p>
 * 版    权: Hunter(c)2020
 * <p>
 * 作    者: Hunter
 * <p>
 * 版    本: V1.0
 * <p>
 * 创建日期: 2020/8/12 10:48
 * <p>
 * 描    述:
 * <p>
 * <p>
 * 修订历史:
 * <p>
 * ================================================================
 */
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<ResultEntity<PhotoBean>> getImageList(String mode, int index, int size, String key) {
        return mHttpDataSource.getImageList(mode, index, size, key);
    }
}