android 当文件夹路径从n层按back键退回到n-19层的时候,file manager自动退出

来源:互联网 发布:中兴通开票软件下载 编辑:程序博客网 时间:2024/05/16 14:56
当文件夹路径从n层按back键退回到n-19层的时候,file manager自动退出,比如在63层按back 键退回到44层的时候,file manager自动退出。
 
1.FileManager默认设计, FileManager种只记录最多20条操作路径的记录, 如果超出就会把最早加入的记录删除. 贵司可以参考alps/mediatek/packages/apps/FileManager/src/com/mediatek/filemanager/FileInfoManager.java中这部分的代码.
    /** Max history size */
    private static final int MAX_LIST_SIZE = 20;
    private final List<NavigationRecord> mNavigationList = new LinkedList<NavigationRecord>();
    /**
     * This method gets the previous navigation directory path
     * 
     * @return the previous navigation path
     */
    protected NavigationRecord getPrevNavigation() {
        while (!mNavigationList.isEmpty()) {
            NavigationRecord navRecord = mNavigationList.get(mNavigationList.size() - 1);
            removeFromNavigationList();
            String path = navRecord.getRecordPath();
            if (!TextUtils.isEmpty(path)) {
                if (new File(path).exists() || MountPointManager.getInstance().isRootPath(path)) {
                    return navRecord;
                }
            }
        }
        return null;
    }
    /**
     * This method adds a navigationRecord to the navigation history
     * 
     * @param navigationRecord the Record
     */
    protected void addToNavigationList(NavigationRecord navigationRecord) {
        if (mNavigationList.size() <= MAX_LIST_SIZE) {
            mNavigationList.add(navigationRecord);
        } else {
            mNavigationList.remove(0);
            mNavigationList.add(navigationRecord);
        }
    }
    /**
     * This method removes a directory path from the navigation history
     */
    protected void removeFromNavigationList() {
        if (!mNavigationList.isEmpty()) {
            mNavigationList.remove(mNavigationList.size() - 1);
        }
    }
 
 
2.对于20条操作路径的history record, 贵司可以修改,只需要把FileInfo.Manager.java中的MAX_LIST_SIZE设为需要的最大路径记录数。这样修改带来的影响是,file manager APK可能会用到更多的内存,因为List<NavigationRecord> mNavigationList需要记录更多的路径数。
alps/mediatek/packages/apps/FileManager/src/com/mediatek/filemanager/FileInfoManager.java中这部分的代码.
    /** Max history size */
    private static final int MAX_LIST_SIZE = xxx;
0 0