码迷,mamicode.com
首页 > 其他好文 > 详细

HotMovie

时间:2016-10-21 16:24:23      阅读:520      评论:0      收藏:0      [点我收藏+]

标签:缓存   odi   rom   as3   drag   sdi   F12   god   bcb   

2016.10.21:

之前的更新都没有贴出来。接下来对应用还会有一些重构,每隔一阶段将更新工作总结一下贴上来,顺路学习下git的命令行操作。

Version:2.2

地址:https://github.com/yusband/HotMovie/tree/HotMovie2.2

New Features:

  • 新增了收藏功能,可以在详情页点击收藏,将电影海报缓存至手机存储卡,在主页面的显示模式中点击“我的收藏”即可获得收藏过电影的列表

技术分享技术分享技术分享技术分享

遇到的坑:

  • 如何看到sqliteDatabase中存储的内容
  1. 使用adb shell工具,通过命令行进入 data/data/包名/databases 之后,出现opendir failed, Permission denied的错误提示
  2. 根据http://stackoverflow.com/questions/19194576/how-do-i-view-the-sqlite-database-on-an-android-device该链接下列出的方法并没有解决问题;采用真机测试(小米5s,api 23)
  3. 最终的解决办法是没有尝试root手机(小米root需要申请...),将程序在avm上运行,直接在DDMS下找到.db文件,在火狐浏览器的SQLite Manager中查看技术分享
  • UriMatcher无法识别Uri的bug
  1. private static final int MOVIE =100 ;
        private static final int MOVIE_ALL =200 ;
        private static final int MOVIE_CERTAIN =300 ;
        private OpenHelper mOpenHelper;
        static UriMatcher buildUriMatcher() {
    
            UriMatcher matcher=new UriMatcher(UriMatcher.NO_MATCH);
    
            final String authority=MovieContact.CONTENT_AUTHORITY;
            matcher.addURI(authority,MovieContact.PATH_MOVIE, MOVIE);
            matcher.addURI(authority,MovieContact.PATH_MOVIE+"/*",MOVIE_ALL);
            matcher.addURI(authority,"movie/#",MOVIE_CERTAIN);
    public int delete(Uri uri, String s, String[] strings) {
            final SQLiteDatabase db = mOpenHelper.getWritableDatabase();
            final int match = sUriMatcher.match(uri);
            int deleteRows=0;
    
            switch (match) {
                case MOVIE_CERTAIN: {
    
                   deleteRows=db.delete(MovieContact.MovieEntry.TABLE_NAME,s,strings);
                    if ( deleteRows<= 0 )
                        throw new android.database.SQLException("Failed to insert row into " + uri);
                    break;
                }
                case MOVIE_ALL: {
    
                    Log.i("movie_all","");
                }
                case  MOVIE:{
                    Log.i("movie","");
                }
                default:
                    throw new UnsupportedOperationException("Unknown uri: " + uri);
            }
            getContext().getContentResolver().notifyChange(uri, null);
            return deleteRows;
    }

    以上是继承自ContentProvider类中的UriMatcher和delete方法,运行会抛出 预定义的UnsupportedOperationException异常

  2. 参考http://stackoverflow.com/questions/5030094/problems-with-androids-urimatcher/15015687#15015687,uriMatcher的识别同定义时addUri的顺序有关:

技术分享

          应当避免在addUri时将*/# 与 */*放在相邻的两行,这里尽管在addUri中定义了如图所示的uri,当match时会因为CONTENT_URI/*在前,而且segment形式一致,会直接返回match CONTENT_URI/*的结果,会抛出异常。

          当在初始化uriMatcher()的过程中,将CONTENT_URI/*和CONTENT_URI/#的顺序交换,便不会抛出异常;这也提醒在定义UriMatcher的过程中,需要注意顺序,格式可以参考官方文档:

sURIMatcher.addURI("contacts", "people", PEOPLE);
        sURIMatcher.addURI("contacts", "people/#", PEOPLE_ID);
        sURIMatcher.addURI("contacts", "people/#/phones", PEOPLE_PHONES);
        sURIMatcher.addURI("contacts", "people/#/phones/#", PEOPLE_PHONES_ID);
        sURIMatcher.addURI("contacts", "people/#/contact_methods", PEOPLE_CONTACTMETHODS);
        sURIMatcher.addURI("contacts", "people/#/contact_methods/#", PEOPLE_CONTACTMETHODS_ID);
        sURIMatcher.addURI("contacts", "deleted_people", DELETED_PEOPLE);
        sURIMatcher.addURI("contacts", "phones", PHONES);
        sURIMatcher.addURI("contacts", "phones/filter/*", PHONES_FILTER);
        sURIMatcher.addURI("contacts", "phones/#", PHONES_ID);
        sURIMatcher.addURI("contacts", "contact_methods", CONTACTMETHODS);
        sURIMatcher.addURI("contacts", "contact_methods/#", CONTACTMETHODS_ID);
        sURIMatcher.addURI("call_log", "calls", CALLS);
        sURIMatcher.addURI("call_log", "calls/filter/*", CALLS_FILTER);
        sURIMatcher.addURI("call_log", "calls/#", CALLS_ID);

 

HotMovie

标签:缓存   odi   rom   as3   drag   sdi   F12   god   bcb   

原文地址:http://www.cnblogs.com/Russel/p/5984789.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!