Skip to content

Commit

Permalink
🔨 UriModelRegistry reame to UriModelManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Flyge committed Oct 29, 2017
1 parent 019c7b8 commit ada2554
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions docs/logs/log_2.6.0_p1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* :hammer: Tile 重命名为 Block
* :hammer: ErrorTracker.onTileSortError() 重命名为 onBlockSortError
* :hammer: 所有 tile 相关的名字 全部改成了 block
* :hammer: UriModelRegistry 重命名为 UriModelManager

sample app:
* :bug: 修复 UNSPLASH 页面没有加载完数据就切换到别的页面时崩溃的 BUG
Expand Down
6 changes: 3 additions & 3 deletions docs/wiki/display_video_thumbnail.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'

2.拷贝 [VideoThumbnailUriModel.java] 到你的 app 中

3.在 Application 中将 [VideoThumbnailUriModel.java] 加入到 [UriModelRegistry] 中,如下:
3.在 Application 中将 [VideoThumbnailUriModel.java] 加入到 [UriModelManager] 中,如下:

```java
Configuration configuration = Sketch.with(context).getConfiguration();
configuration.getUriModelRegistry().add(new VideoThumbnailUriModel());
configuration.getUriModelManager().add(new VideoThumbnailUriModel());
```

4.显示视频缩略图
Expand All @@ -47,4 +47,4 @@ sketchImageView.displayImage(videoFileUri);
[sample-video-thumbnail]: ../../sample-video-thumbnail/
[FFmpegMediaMetadataRetriever]: https://github.com/wseemann/FFmpegMediaMetadataRetriever
[VideoThumbnailUriModel.java]: ../../sample-video-thumbnail/src/main/java/me/xiaopan/ssvt/VideoThumbnailUriModel.java
[UriModelRegistry]: ../../sketch/src/main/java/me/xiaopan/sketch/uri/UriModelRegistry.java
[UriModelManager]: ../../sketch/src/main/java/me/xiaopan/sketch/uri/UriModelManager.java
2 changes: 1 addition & 1 deletion docs/wiki/initializer.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class MyInitializer implements Initializer {

@Override
public void onInitialize(Context context, Configuration configuration) {
configuration.getUriModelRegistry().add(new XpkIconUriModel());
configuration.getUriModelManager().add(new XpkIconUriModel());
configuration.setErrorTracker(new MyErrorTracker(context));
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/memory_cache_state_image.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class ImageFragment extends Fragment {
DisplayOptions options = sketchImageView.getOptions();

Configuration configuration = Sketch.with(getActivity()).getConfiguration();
UriModel uriModel = configuration.getUriModelRegistry().match(imageUri);
UriModel uriModel = configuration.getUriModelManager().match(imageUri);
String loadingImageMemoryCacheKey = SketchUtils.makeRequestKey(imageUri, uriModel, optionsKey);
options.setLoadingImage(new MemoryCacheStateImage(loadingImageMemoryCacheKey, null));

Expand Down
2 changes: 1 addition & 1 deletion docs/wiki/uri_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ if (uriModel.isFromNet()){
```java
Configuration configuration = ...;

configuration.getUriModelRegistry().add(new MyUriModel());
configuration.getUriModelManager().add(new MyUriModel());
```

#### AbsDiskCacheUriModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import me.xiaopan.sketch.Initializer
class SketchInitializer : Initializer {

override fun onInitialize(context: Context, configuration: Configuration) {
configuration.uriModelRegistry.add(VideoThumbnailUriModel())
configuration.uriModelManager.add(VideoThumbnailUriModel())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SampleSketchInitializer : Initializer {

configuration!!.errorTracker = SampleErrorTracker(context!!)

configuration!!.uriModelRegistry.add(XpkIconUriModel())
configuration!!.uriModelManager.add(XpkIconUriModel())
}

@Subscribe
Expand Down
14 changes: 7 additions & 7 deletions sketch/src/main/java/me/xiaopan/sketch/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import me.xiaopan.sketch.request.RequestFactory;
import me.xiaopan.sketch.request.Resize;
import me.xiaopan.sketch.uri.UriModel;
import me.xiaopan.sketch.uri.UriModelRegistry;
import me.xiaopan.sketch.uri.UriModelManager;

/**
* {@link Sketch} 唯一配置类
Expand All @@ -61,7 +61,7 @@ public final class Configuration {

private Context context;

private UriModelRegistry uriModelRegistry;
private UriModelManager uriModelManager;
private OptionsFilterRegistry optionsFilterRegistry;

private DiskCache diskCache;
Expand Down Expand Up @@ -89,7 +89,7 @@ public final class Configuration {
context = context.getApplicationContext();
this.context = context;

this.uriModelRegistry = new UriModelRegistry();
this.uriModelManager = new UriModelManager();
this.optionsFilterRegistry = new OptionsFilterRegistry();

// 由于默认的缓存文件名称从 URLEncoder 加密变成了 MD5 所以这里要升级一下版本号,好清除旧的缓存
Expand Down Expand Up @@ -132,11 +132,11 @@ public Context getContext() {
/**
* 获取 {@link UriModel} 管理器
*
* @return {@link UriModelRegistry}. {@link UriModel} 管理器
* @return {@link UriModelManager}. {@link UriModel} 管理器
*/
@NonNull
public UriModelRegistry getUriModelRegistry() {
return uriModelRegistry;
public UriModelManager getUriModelManager() {
return uriModelManager;
}

/**
Expand Down Expand Up @@ -751,7 +751,7 @@ public Configuration setMobileDataPauseDownloadEnabled(boolean mobileDataPauseDo
@NonNull
public String getInfo() {
return NAME + ": " +
"\n" + "uriModelRegistry:" + uriModelRegistry.getKey() +
"\n" + "uriModelManager:" + uriModelManager.getKey() +
"\n" + "optionsFilterRegistry:" + optionsFilterRegistry.getKey() +

"\n" + "diskCache:" + diskCache.getKey() +
Expand Down
2 changes: 1 addition & 1 deletion sketch/src/main/java/me/xiaopan/sketch/uri/UriModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class UriModel {
*/
@Nullable
public static UriModel match(@NonNull Sketch sketch, @NonNull String uri) {
return !TextUtils.isEmpty(uri) ? sketch.getConfiguration().getUriModelRegistry().match(uri) : null;
return !TextUtils.isEmpty(uri) ? sketch.getConfiguration().getUriModelManager().match(uri) : null;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
/**
* 负责管理和匹配 {@link UriModel}
*/
public class UriModelRegistry implements Identifier{
public class UriModelManager implements Identifier{
private List<UriModel> uriModelList = new LinkedList<>();

public UriModelRegistry() {
public UriModelManager() {
this.uriModelList.add(new HttpUriModel());
this.uriModelList.add(new HttpsUriModel());
this.uriModelList.add(new FileUriModel());
Expand All @@ -47,7 +47,7 @@ public UriModelRegistry() {
}

@NonNull
public UriModelRegistry add(@NonNull UriModel uriModel) {
public UriModelManager add(@NonNull UriModel uriModel) {
//noinspection ConstantConditions
if (uriModel != null) {
uriModelList.add(uriModel);
Expand All @@ -56,7 +56,7 @@ public UriModelRegistry add(@NonNull UriModel uriModel) {
}

@NonNull
public UriModelRegistry add(int index, @NonNull UriModel uriModel) {
public UriModelManager add(int index, @NonNull UriModel uriModel) {
//noinspection ConstantConditions
if (uriModel != null) {
uriModelList.add(index, uriModel);
Expand Down Expand Up @@ -85,6 +85,6 @@ public UriModel match(@NonNull String uri) {
@NonNull
@Override
public String getKey() {
return "UriModelRegistry";
return "UriModelManager";
}
}

0 comments on commit ada2554

Please sign in to comment.