先导入http,fanfou, data包,会在如下问题报错:
1,对于com.ch_linghu.fanfoudroid.TwitterApplication.DEBUG的引用。
2,对于string.xml的引用。
3,fanfou包中个别模块会用到数据库。
4, 上述包还会引用业务无关的基础代码,如util。
我的处理是:
1,新造一个com.ch_linghu.fanfoudroid.TwitterApplication,用来保存需要的常量。
2,在相关模块里简单地修改代码,转向引用新的TwitterApplication。
//import com.ch_linghu.fanfoudroid.R;
import com.ch_linghu.fanfoudroid.TwitterApplication;
// sb.append(R.string.pref_rt_prefix_default + ":@");
sb.append(TwitterApplication.pref_rt_prefix_default + ":@");
3,对于个别模块里遇到数据库相关代码,注释掉就可以了。
比如在com.ch_linghu.fanfoudroid.fanfou.User中,
//import com.ch_linghu.fanfoudroid.db.MessageTable;
//import com.ch_linghu.fanfoudroid.db.TwitterDatabase;
//import com.ch_linghu.fanfoudroid.db.UserInfoTable;
/*
//TODO:增加从游标解析User的方法,用于和data里User转换一条数据
public static User parseUser(Cursor cursor){
4,完整地引入util包,注意在util包里也会引用string.xml。
5,最终TwitterApplication很简单,
public class TwitterApplication
{
public final static boolean DEBUG = true; // Configuration.getDebug();
public final static String pref_rt_prefix_default = "热饭";
public final static String tweet_source_prefix = "来自";
public final static String tweet_reply_to_prefix = "给";
public final static String tweet_reply_to_suffix = "的回复";
public final static String tweet_created_at_beautify_prefix = "大约";
public final static String tweet_created_at_beautify_sec = "秒";
public final static String tweet_created_at_beautify_min = "分钟";
public final static String tweet_created_at_beautify_hour = "小时";
public final static String tweet_created_at_beautify_day = "天";
public final static String tweet_created_at_beautify_suffix = "前";
public final static String pref_photo_preview_type_thumbnail = "缩略图尺寸";
public final static String pref_photo_preview_type_middle = "小尺寸";
public final static String pref_photo_preview_type_original = "大尺寸";
一点感想:
仅从代码复用的考虑出发,
1,问题集中在字符串资源上。
fanfou包是否可以有自己的字符串资源?
util、http包里string.xml相关的代码是否可以集中到fanfou包里?
2,fanfou包是否可以和数据库无关?
3, 正因为如此的简单,如果再进一步,拿过来就可以用,就好了。
=======================================================================
备注:
导入代码时遇到注释乱码的问题,解决如下:
对不起,忘了保留参考url。
No comments:
Post a Comment