launcher 桌面启动器的DB文件数据处理操作
来源:互联网 发布:鹿晗颜值如何 知乎 编辑:程序博客网 时间:2024/06/05 03:43
launcher-----启动器中的launcher.db文件的数据处理方法:
主要是查询,更新数据:
/** * 类描述:缩略图帮助类 * @author hexiaoming * @version */public class PreviewHelper {/********WorkspaceScreen的最大值*******/public static final int MaxWorkspaceScreen = 40;private Context context = null;public static final String Preview_Helper = "Preview_Helper";public static final String AUTHORITY = "com.konka.launcher2.settings";public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/" + "favorites" + "?" + "notify" + "=true");//Uri.parse("content://" + AUTHORITY + "favorites");private static String[] projection = new String[] {"container","screen"}; private static String[] projection_delete = new String[] {"_id","container","screen"}; public static final int CONTAINER_DESKTOP = -100;/** * 方法描述:PreviewHelper的构造方法* @param * @return * @see PreviewHelper*/public PreviewHelper(Context context) {this.context = context;}/** * 方法描述:getArrayListForScreenIsNull方法,获取表示当前界面是否没有APP和Weight的ArrayList* @param * @return ArrayList<Boolean>* @see PreviewHelper*/public Boolean[] getScreenIsNull(){int length = LauncherPreviewActivity.bitmaps.size();Boolean[] screenIsNull = new Boolean[length] ; for(int i=0;i<screenIsNull.length;i++) { screenIsNull[i] = true; } final ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( CONTENT_URI, projection, null, null, null); final int containerIndex = c.getColumnIndexOrThrow(projection[0]); final int screenIndex = c.getColumnIndexOrThrow(projection[1]); int container; int screen; try { while (c.moveToNext()) { container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { screenIsNull[screen] = false; } } } catch (Exception e) { } finally { c.close(); }return screenIsNull;}/** * 方法描述:ProcessDBForDeletePreviewScreen方法,处理删除缩略图片item_delete时的launcher.db数据* @param int item_delete * @return void* @see PreviewHelper*/public void ProcessDBForDeletePreviewScreen(int item_delete){ final ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( CONTENT_URI, projection_delete, null, null, null); final int favoriteIdIndex = c.getColumnIndexOrThrow(projection_delete[0]); final int containerIndex = c.getColumnIndexOrThrow(projection_delete[1]); final int screenIndex = c.getColumnIndexOrThrow(projection_delete[2]); int favoritedId; int container; int screen; ContentValues values = new ContentValues(); try { while (c.moveToNext()) { favoritedId = c.getInt(favoriteIdIndex); container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { if(screen > item_delete) { values.clear(); values.put("SCREEN", screen - 1); String updateWhere = "_id" + "=" + favoritedId; // String updateWhere = "(" + "SCREEN" + " == 'screen' " + ")" + "AND"// + "(" + "container" + "== 'container'" + ")" ; // BluetoothShare.STATUS + " >= '200' AND " + "(" + BluetoothShare.VISIBILITY + " IS NULL OR "// + BluetoothShare.VISIBILITY + " == '" + BluetoothShare.VISIBILITY_VISIBLE + "'" + ")"; cr.update( CONTENT_URI, values, updateWhere, null);} } } } catch (Exception e) { } finally { c.close(); }}/** * 方法描述:ProcessDBForExchangePreviewScreen方法,处理拖动缩略图片时的launcher.db数据* @param int start_item,int end_item * @return void* @see PreviewHelper*/public void ProcessDBForExchangePreviewScreen(int start_item,int end_item){final ContentResolver cr = context.getContentResolver(); Cursor c = cr.query( CONTENT_URI, projection_delete, null, null, null); final int favoriteIdIndex = c.getColumnIndexOrThrow(projection_delete[0]); final int containerIndex = c.getColumnIndexOrThrow(projection_delete[1]); final int screenIndex = c.getColumnIndexOrThrow(projection_delete[2]); int favoritedId; int container; int screen; ContentValues values = new ContentValues();if(start_item < end_item){ try { while (c.moveToNext()) { favoritedId = c.getInt(favoriteIdIndex); container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { if(screen == start_item) { values.clear(); values.put("SCREEN", end_item); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } if(screen > start_item && screen <= end_item) { values.clear(); values.put("SCREEN", screen - 1); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } } } } catch (Exception e) { } finally { c.close(); }}if(start_item > end_item){ try { while (c.moveToNext()) { favoritedId = c.getInt(favoriteIdIndex); container = c.getInt(containerIndex); screen = c.getInt(screenIndex); if(container == CONTAINER_DESKTOP) { if(screen == start_item) { values.clear(); values.put("SCREEN", end_item); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } if(screen >= end_item && screen < start_item) { values.clear(); values.put("SCREEN", screen + 1); String updateWhere = "_id" + "=" + favoritedId; cr.update( CONTENT_URI, values, updateWhere, null); } } } } catch (Exception e) { } finally { c.close(); }}}}
- launcher 桌面启动器的DB文件数据处理操作
- 安卓系统中的桌面启动器Launcher
- Linux 桌面启动器 文件实例
- GridView实现简单的应用启动器Launcher
- ubuntu创建桌面启动器的方法
- ubuntu创建桌面启动器的方法
- Ubuntu16桌面启动器的移动方式
- 改变Ubuntu16.04桌面启动器的位置
- WP7 Launcher 启动器
- Android launcher启动器
- Android——Launcher(桌面启动器)相关知识总结贴
- Ubuntu16.04 桌面左侧(Launcher)启动器与屏幕底部互换
- Linux下桌面启动器(桌面配置文件)的创建
- 定制你自己的桌面--- launcher
- 定制自己的桌面:launcher
- 创建并使用Linux 桌面启动器(.Desktop文件)
- MTK Launcher 应用的包名以及意图launcher.db
- ubuntu 创建桌面启动器
- String 类的equal方法源代码
- android 获取系统应用
- 分布式协调器ZooKeeper3.4—管理员手册
- 如何用Cocos2d来开发简单的iPhone游戏教程
- ffmpeg android编译
- launcher 桌面启动器的DB文件数据处理操作
- Activity的属性
- 内存三种分配方式
- unity基础开发-- 动态加载游戏对象或文件
- OXC和OADM
- 水果 hdu1263 水题
- 全面整理的C++面试题(II)
- ubuntu源码安装openssh
- Linux 脚本之字符串截断