dileber android 框架:乁( ˙Ω˙ )厂 跳转链接 dileber android框架
怎么说呢?既然看到了就在github上star一下呗 (´ཀ`」 ∠)
最近我将一个用dileber 项目开发的示例软件提交到github上:
myshop软件
采用mvp模式开发项目
该项目使用了框架中的
- 网络请求
- cookies 使用
- 自动判断cookies失效
- 日志打印系统
- 字体图标系统
SHOPApplication
开启日志打印系统,开启默认字体图标
public class SHOPApplication extends SApplication{
@Override
public void start() {
loadDeaultFont = true;
crash = true;
}
@Override
protected void init() {
}
@Override
public void appForbidden(final Call call, Response response, final RetCallback retCallback) {
TCookie.clearCookie();
UDialog.dialogOk("登录过时,重新登录?", new DialogLinstener() {
@Override
public void confirm(Dialog dialog) {
String login_name = (SHOPPrefer.get(SHOPPrefer.USERNAME,"",String.class));
String login_pass = (SHOPPrefer.get(SHOPPrefer.USERPASS,"",String.class));
UserRepository.getInstance().login(login_name, MD5.getStringMD5(login_pass), new BaseDataSource.BaseCallback<UserWrapper>() {
@Override
public void onSuccess(UserWrapper userWrapper) {
if(userWrapper.getState()== 0){
call.clone().enqueue(retCallback);
}else if(userWrapper.getState()==-1){
UUi.toast(ActivityManager.getCurrentActivity(),userWrapper.getMsg(), Toast.LENGTH_SHORT);
LoginActivity.start(ActivityManager.getCurrentActivity());
ActivityManager.getInstance(BaseShopActivity.activityStack).finishAllActivity();
}
}
@Override
public void onFailure(DataSourceException e) {
UUi.toast(ActivityManager.getCurrentActivity(),e.getMessage(), Toast.LENGTH_SHORT);
LoginActivity.start(ActivityManager.getCurrentActivity());
ActivityManager.getInstance(BaseShopActivity.activityStack).finishAllActivity();
}
});
dialog.dismiss();
}
@Override
public void cancel(Dialog dialog) {
LoginActivity.start(ActivityManager.getCurrentActivity());
ActivityManager.getInstance(BaseShopActivity.activityStack).finishAllActivity();
dialog.dismiss();
}
}).show();
}
}
SHOPConfig
配置debug开启,配置url
public class SHOPConfig extends BaseConfiger{
static {
BUG_NAME = "SHOPApplication";
BUG_STATIC = true;
}
public final static String URL = "http://shop.dreamsoso.com/";
}
SHOPPrefer
配置存储,shareprefer
public class SHOPPrefer {
public final static String SAREPREFER_SHOP = "sareprefer_shop";
public final static String USERNAME = "username";
public final static String USERPASS = "userpass";
public static void push(String key,Object value){
HPref.getInstance().put(SAREPREFER_SHOP,key,value);
}
public static <T>T get(String key, T defaultValue,Class<T> returnType){
return HPref.getInstance().get(SAREPREFER_SHOP,key,defaultValue,returnType);
}
}
如何控制某几个activity一起finish
在BaseShopActivity 中将特定的acitivity加入到某个栈中
public abstract class BaseShopActivity extends UBaseActivity {
public final static String activityStack = "shop";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(!(this instanceof LoginActivity)){
ActivityManager.getInstance(activityStack).pushActivity(this);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if(!(this instanceof LoginActivity)){
ActivityManager.getInstance(activityStack).popActivity(this);
}
}
}
详细的代码就在
github上:
myshop软件
點(diǎn)擊查看更多內(nèi)容
1人點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫(xiě)下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶(hù)
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得
100積分直接送
付費(fèi)專(zhuān)欄免費(fèi)學(xué)
大額優(yōu)惠券免費(fèi)領(lǐng)