-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
next:接入到红客中去
- Loading branch information
Showing
25 changed files
with
367 additions
and
288 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
Glide&OKHttp/Gilde&OkHttp/src/androidTest/java/com/glide/ApplicationTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
Glide&OKHttp/Gilde&OkHttp/src/main/java/com/glide/activity/InnerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.glide.activity; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.yline.log.LogFileUtil; | ||
import com.yline.test.BaseTestActivity; | ||
import com.yline.utils.FileSizeUtil; | ||
|
||
public class InnerActivity extends BaseTestActivity | ||
{ | ||
@Override | ||
protected void testStart(final Bundle savedInstanceState) | ||
{ | ||
addButton("使用Glide", new View.OnClickListener() | ||
{ | ||
@Override | ||
public void onClick(View v) | ||
{ | ||
SampleSingleActivity.actionStart(InnerActivity.this); | ||
} | ||
}); | ||
|
||
addButton("查看缓存大小", new View.OnClickListener() | ||
{ | ||
@Override | ||
public void onClick(View v) | ||
{ | ||
long size = FileSizeUtil.getDirSize(InnerActivity.this.getExternalFilesDir("GlidePicture")); | ||
LogFileUtil.v("DirSize = " + size); | ||
} | ||
}); | ||
|
||
addButton("清除内存缓存", new View.OnClickListener() | ||
{ | ||
@Override | ||
public void onClick(View v) | ||
{ | ||
Glide.get(InnerActivity.this).clearMemory(); // 清理内存缓存 只能在UI主线程中进行 | ||
} | ||
}); | ||
|
||
addButton("清除磁盘缓存", new View.OnClickListener() | ||
{ | ||
@Override | ||
public void onClick(View v) | ||
{ | ||
new Thread(new Runnable() | ||
{ | ||
@Override | ||
public void run() | ||
{ | ||
Glide.get(InnerActivity.this).clearDiskCache(); | ||
} | ||
}).start(); | ||
} | ||
}); | ||
} | ||
} |
67 changes: 0 additions & 67 deletions
67
Glide&OKHttp/Gilde&OkHttp/src/main/java/com/glide/activity/ListActivity.java
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
Glide&OKHttp/Gilde&OkHttp/src/main/java/com/glide/activity/MainActivity.java
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
Glide&OKHttp/Gilde&OkHttp/src/main/java/com/glide/activity/MainApplication.java
This file was deleted.
Oops, something went wrong.
88 changes: 88 additions & 0 deletions
88
Glide&OKHttp/Gilde&OkHttp/src/main/java/com/glide/activity/SampleSingleActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.glide.activity; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.widget.ImageView; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
import com.glide.R; | ||
import com.glide.helper.DeleteConstant; | ||
import com.yline.base.BaseAppCompatActivity; | ||
import com.yline.common.CommonRecyclerAdapter; | ||
import com.yline.common.CommonRecyclerViewHolder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class SampleSingleActivity extends BaseAppCompatActivity | ||
{ | ||
private SampleSingleAdapter recyclerAdapter; | ||
|
||
private List<String> dataList; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) | ||
{ | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_sample_single); | ||
|
||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_sample_single); | ||
recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); | ||
recyclerAdapter = new SampleSingleAdapter(); | ||
recyclerView.setAdapter(recyclerAdapter); | ||
|
||
initData(); | ||
} | ||
|
||
private void initData() | ||
{ | ||
dataList = new ArrayList<>(); | ||
for (int i = 0; i < 30; i++) | ||
{ | ||
dataList.add(DeleteConstant.getUrlSquare()); | ||
} | ||
recyclerAdapter.addAll(dataList); | ||
} | ||
|
||
private class SampleSingleAdapter extends CommonRecyclerAdapter<String> | ||
{ | ||
public SampleSingleAdapter() | ||
{ | ||
sList = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public int getItemRes() | ||
{ | ||
return R.layout.item_sample_single; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(CommonRecyclerViewHolder viewHolder, int position) | ||
{ | ||
viewHolder.setText(R.id.tv_title, sList.get(position)); | ||
|
||
ImageView imageView = viewHolder.get(R.id.iv_title); | ||
Glide.with(SampleSingleActivity.this) // 初始化 | ||
.load(sList.get(position)) // 下载资源 | ||
.asBitmap() // 确认是静态图片,就不加载动态了 | ||
.override(400, 400) // 设置加载的图片尺寸 | ||
.placeholder(R.mipmap.global_load_failed) // 占位图(图形和将要加载的图,需要保持比例一致;否则会导致拉伸) | ||
.diskCacheStrategy(DiskCacheStrategy.RESULT) // 占位符 默认RESULT | ||
.error(R.mipmap.global_load_failed) | ||
.into(imageView); // 放置到View中 | ||
/* | ||
Glide.get(SampleSingleActivity.this).clearDiskCache(); // 清理磁盘缓存 需要在子线程中执行 | ||
Glide.get(SampleSingleActivity.this).clearMemory(); // 清理内存缓存 可以在UI主线程中进行*/ | ||
} | ||
} | ||
|
||
public static void actionStart(Context context) | ||
{ | ||
context.startActivity(new Intent(context, SampleSingleActivity.class)); | ||
} | ||
} |
Oops, something went wrong.