-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f3f48b
commit 808843e
Showing
33 changed files
with
1,399 additions
and
153 deletions.
There are no files selected for viewing
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
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
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
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
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
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
73 changes: 73 additions & 0 deletions
73
app/src/main/java/com/youth/xf/ui/demo/XCacheActivity.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,73 @@ | ||
package com.youth.xf.ui.demo; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.youth.xf.BaseActivity; | ||
import com.youth.xf.R; | ||
import com.youth.xf.bean.News; | ||
import com.youth.xframe.cache.XCache; | ||
import com.youth.xframe.utils.XOutdatedUtils; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Arrays; | ||
|
||
public class XCacheActivity extends BaseActivity { | ||
|
||
TextView cacheText; | ||
ImageView cacheImage; | ||
XCache xCache; | ||
|
||
@Override | ||
public int getLayoutId() { | ||
return R.layout.activity_xcache; | ||
} | ||
|
||
@Override | ||
public void initData(Bundle savedInstanceState) { | ||
|
||
} | ||
|
||
@Override | ||
public void initView() { | ||
cacheText = (TextView) findViewById(R.id.cacheText); | ||
cacheImage = (ImageView) findViewById(R.id.cacheImage); | ||
xCache=XCache.get(this); | ||
xCache.put("string","缓存普通字符串"); | ||
News news=new News(News.TYPE_SINGLE_PICTURE,"智能手机行业正处于关键转折点,下一战场会在哪里?","https://pic.36krcnd.com/avatar/201701/17062818/1ucsedy4pdb4aqyu.jpg!heading","缪定纯•明星公司","58分钟前"); | ||
xCache.put("news",news);//保存序列化对象 | ||
xCache.put("bitmap", BitmapFactory.decodeResource(getResources(), R.mipmap.computer)); | ||
xCache.put("drawable", XOutdatedUtils.getDrawable(R.mipmap.computer)); | ||
xCache.put("byte", "缓存byte".getBytes());//字节数组,使用场景很多,这里只做测试 | ||
/** | ||
* 关于实体类保存,建议用json字符串保存,效果更佳,兼容性更好 | ||
*/ | ||
} | ||
|
||
public void onClick(View v) { | ||
switch (v.getId()){ | ||
case R.id.button1: | ||
cacheText.setText(xCache.getAsString("string")); | ||
break; | ||
case R.id.button2: | ||
cacheImage.setImageBitmap(xCache.getAsBitmap("bitmap")); | ||
break; | ||
case R.id.button3: | ||
cacheImage.setImageDrawable(xCache.getAsDrawable("drawable")); | ||
break; | ||
case R.id.button4: | ||
cacheText.setText(((News)xCache.getAsObject("news")).toString()); | ||
break; | ||
case R.id.button5: | ||
cacheText.setText(new String(xCache.getAsBinary("byte"))); | ||
break; | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.