• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Utils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中group.pals.android.lib.ui.filechooser.utils.Utils的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Utils类属于group.pals.android.lib.ui.filechooser.utils包,在下文中一共展示了Utils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onTouch

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public boolean onTouch(View v, MotionEvent event) {
    if (Utils.doLog())
        Log.d(CLASSNAME,
                "mImageIconOnTouchListener.onTouch() >> ACTION = "
                        + event.getAction());

    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        v.setBackgroundResource(R.drawable.afc_image_button_dark_pressed);
        break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_CANCEL:
        v.setBackgroundResource(0);
        break;
    }
    return false;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:19,代码来源:BaseFileAdapter.java


示例2: onKeyDown

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (Utils.doLog())
        Log.d(CLASSNAME, String.format("onKeyDown() >> %,d", keyCode));

    if (keyCode == KeyEvent.KEYCODE_BACK) {
        /*
         * Use this hook instead of onBackPressed(), because onBackPressed()
         * is not available in API 4.
         */
        if (mFragmentFiles.isLoading()) {
            if (Utils.doLog())
                Log.d(CLASSNAME,
                        "onKeyDown() >> KEYCODE_BACK >> cancelling previous query...");
            mFragmentFiles.cancelPreviousLoader();
            Dlg.toast(this, R.string.afc_msg_cancelled, Dlg.LENGTH_SHORT);
            return true;
        }
    }

    return super.onKeyDown(keyCode, event);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:23,代码来源:FileChooserActivity.java


示例3: FileObserverEx

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
/**
 * Creates new instance.
 * 
 * @param context
 *            the context.
 * @param path
 *            the path to the directory that you want to watch for changes.
 */
public FileObserverEx(final Context context, final String path,
        final Uri notificationUri) {
    super(path, FILE_OBSERVER_MASK);

    mHandlerThread.start();
    mHandler = new Handler(mHandlerThread.getLooper()) {

        @Override
        public void handleMessage(Message msg) {
            if (Utils.doLog())
                Log.d(CLASSNAME,
                        String.format(
                                "mHandler.handleMessage() >> path = '%s' | what = %,d",
                                path, msg.what));

            switch (msg.what) {
            case MSG_NOTIFY_CHANGES:
                context.getContentResolver().notifyChange(notificationUri,
                        null);
                mLastEventTime = SystemClock.elapsedRealtime();
                break;
            }
        }// handleMessage()
    };
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:34,代码来源:FileObserverEx.java


示例4: onEvent

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public void onEvent(int event, String path) {
    /*
     * Some bugs of Android...
     */
    if (!mWatching || event == FILE_OBSERVER_UNKNOWN_EVENT || path == null
            || mHandler.hasMessages(MSG_NOTIFY_CHANGES)
            || !mHandlerThread.isAlive() || mHandlerThread.isInterrupted())
        return;

    try {
        if (SystemClock.elapsedRealtime() - mLastEventTime <= MIN_TIME_BETWEEN_EVENTS)
            mHandler.sendEmptyMessageDelayed(
                    MSG_NOTIFY_CHANGES,
                    Math.max(
                            1,
                            MIN_TIME_BETWEEN_EVENTS
                                    - (SystemClock.elapsedRealtime() - mLastEventTime)));
        else
            mHandler.sendEmptyMessage(MSG_NOTIFY_CHANGES);
    } catch (Throwable t) {
        mWatching = false;
        if (Utils.doLog())
            Log.e(CLASSNAME, "onEvent() >> " + t);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:27,代码来源:FileObserverEx.java


示例5: afterTextChanged

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
    if (Utils.doLog())
        Log.d(CLASSNAME,
                "afterTextChanged() >>> delayTimeSubmission = "
                        + getDelayTimeSubmission());

    if (TextUtils.isEmpty(mTextSearch.getText())) {
        if (!isClosable())
            mButtonClear.setVisibility(GONE);
    } else
        mButtonClear.setVisibility(VISIBLE);

    if (getDelayTimeSubmission() > 0)
        mAutoSubmissionHandler.postDelayed(mAutoSubmissionRunnable,
                getDelayTimeSubmission());
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:18,代码来源:AfcSearchView.java


示例6: checkConditionsThenConfirmUserToCreateNewDir

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
/**
 * Checks current conditions to see if we can create new directory. Then
 * confirms user to do so.
 */
private void checkConditionsThenConfirmUserToCreateNewDir() {
    if (LocalFileContract.getAuthority(getActivity()).equals(
            mFileProviderAuthority)
            && !Utils.hasPermissions(getActivity(),
                    Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
        Dlg.toast(
                getActivity(),
                R.string.afc_msg_app_doesnot_have_permission_to_create_files,
                Dlg.LENGTH_SHORT);
        return;
    }

    new LoadingDialog<Void, Void, Boolean>(getActivity(), false) {

        @Override
        protected Boolean doInBackground(Void... params) {
            return getCurrentLocation() != null
                    && BaseFileProviderUtils.fileCanWrite(getActivity(),
                            getCurrentLocation());
        }// doInBackground()

        @Override
        protected void onPostExecute(Boolean result) {
            super.onPostExecute(result);

            if (result)
                showNewDirectoryCreationDialog();
            else
                Dlg.toast(getActivity(),
                        R.string.afc_msg_cannot_create_new_folder_here,
                        Dlg.LENGTH_SHORT);
        }// onProgressUpdate()

    }.execute();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:40,代码来源:FragmentFiles.java


示例7: query

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {
    if (Utils.doLog())
        Log.d(CLASSNAME, String.format(
                "query() >> uri = %s (%s) >> match = %s", uri,
                uri.getLastPathSegment(), URI_MATCHER.match(uri)));

    switch (URI_MATCHER.match(uri)) {
    case URI_API: {
        /*
         * If there is no command given, return provider ID and name.
         */
        MatrixCursor matrixCursor = new MatrixCursor(new String[] {
                BaseFile.COLUMN_PROVIDER_ID, BaseFile.COLUMN_PROVIDER_NAME,
                BaseFile.COLUMN_PROVIDER_ICON_ATTR });
        matrixCursor.newRow().add(LocalFileContract._ID)
                .add(getContext().getString(R.string.afc_phone))
                .add(R.attr.afc_badge_file_provider_localfile);
        return matrixCursor;
    }
    case URI_API_COMMAND: {
        return doAnswerApiCommand(uri);
    }// URI_API

    case URI_DIRECTORY: {
        return doListFiles(uri);
    }// URI_DIRECTORY

    case URI_FILE: {
        return doRetrieveFileInfo(uri);
    }// URI_FILE

    default:
        throw new IllegalArgumentException("UNKNOWN URI " + uri);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:38,代码来源:LocalFileProvider.java


示例8: extractFile

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
/**
 * Extracts source file from request URI.
 * 
 * @param uri
 *            the original URI.
 * @return the file.
 */
private static File extractFile(Uri uri) {
    String fileName = Uri.parse(uri.getLastPathSegment()).getPath();
    if (uri.getQueryParameter(BaseFile.PARAM_APPEND_PATH) != null)
        fileName += Uri.parse(
                uri.getQueryParameter(BaseFile.PARAM_APPEND_PATH))
                .getPath();
    if (uri.getQueryParameter(BaseFile.PARAM_APPEND_NAME) != null)
        fileName += "/" + uri.getQueryParameter(BaseFile.PARAM_APPEND_NAME);

    if (Utils.doLog())
        Log.d(CLASSNAME, "extractFile() >> " + fileName);

    return new File(fileName);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:22,代码来源:LocalFileProvider.java


示例9: startWatching

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public void startWatching() {
    super.startWatching();

    if (Utils.doLog())
        Log.d(CLASSNAME, String.format("startWatching() >> %s", hashCode()));

    mWatching = true;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:10,代码来源:FileObserverEx.java


示例10: stopWatching

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public void stopWatching() {
    super.stopWatching();

    if (Utils.doLog())
        Log.d(CLASSNAME, String.format("stopWatching() >> %s", hashCode()));

    mWatching = false;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR)
        HandlerThreadCompat_v5.quit(mHandlerThread);
    mHandlerThread.interrupt();
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:14,代码来源:FileObserverEx.java


示例11: beforeTextChanged

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
        int after) {
    if (Utils.doLog())
        Log.d(CLASSNAME, "beforeTextChanged()");
    mAutoSubmissionHandler.removeCallbacksAndMessages(null);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:8,代码来源:AfcSearchView.java


示例12: query

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {
    if (Utils.doLog())
        Log.d("KP2A_FC_P", String.format(
                "query() >> uri = %s (%s) >> match = %s", uri,
                uri.getLastPathSegment(), URI_MATCHER.match(uri)));

    switch (URI_MATCHER.match(uri)) {
    case URI_API: {
        /*
         * If there is no command given, return provider ID and name.
         */
        MatrixCursor matrixCursor = new MatrixCursor(new String[] {
                BaseFile.COLUMN_PROVIDER_ID, BaseFile.COLUMN_PROVIDER_NAME,
                BaseFile.COLUMN_PROVIDER_ICON_ATTR });
        matrixCursor.newRow().add(_ID)
                .add("KP2A")
                .add(R.attr.afc_badge_file_provider_localfile);
        return matrixCursor;
    }
    case URI_API_COMMAND: {
        return doAnswerApiCommand(uri);
    }// URI_API

    case URI_DIRECTORY: {
        return doListFiles(uri);
    }// URI_DIRECTORY

    case URI_FILE: {
        return doRetrieveFileInfo(uri);
    }// URI_FILE

    default:
        throw new IllegalArgumentException("UNKNOWN URI " + uri);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:38,代码来源:Kp2aFileProvider.java


示例13: getFileEntryCached

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
private FileEntry getFileEntryCached(String filename) {
   	//check if enry is cached:
   	FileEntry cachedEntry = fileEntryMap.get(filename);
   	if (cachedEntry != null)
   	{
   		if (Utils.doLog())
   			Log.d(CLASSNAME, "getFileEntryCached: from cache. " + filename);
   		return cachedEntry;
   	}
   	
	if (Utils.doLog())
		Log.d(CLASSNAME, "getFileEntryCached: not in cache :-( " + filename);


       FileEntry newEntry ;
       try {
           //it's not -> query the information.
          newEntry = getFileEntry(filename, null);
       } catch (Exception e) {
           e.printStackTrace();
           return null;
       }
	
	if (!cacheBlockedFiles.contains(filename))
		updateFileEntryCache(newEntry);
	
	return newEntry;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:29,代码来源:Kp2aFileProvider.java


示例14: doCheckAncestor

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
/**
 * Checks ancestor with {@link BaseFile#CMD_IS_ANCESTOR_OF},
 * {@link BaseFile#PARAM_SOURCE} and {@link BaseFile#PARAM_TARGET}.
 * 
 * @param uri
 *            the original URI from client.
 * @return {@code null} if source is not ancestor of target; or a
 *         <i>non-null but empty</i> cursor if the source is.
 */
private MatrixCursor doCheckAncestor(Uri uri) {
    String source = Uri.parse(
            uri.getQueryParameter(BaseFile.PARAM_SOURCE)).toString();
    String target = Uri.parse(
            uri.getQueryParameter(BaseFile.PARAM_TARGET)).toString();
    if (source == null || target == null)
        return null;

    boolean validate = ProviderUtils.getBooleanQueryParam(uri,
            BaseFile.PARAM_VALIDATE, true);
    if (validate) {
     //not supported
    }
    
    if (!source.endsWith("/"))
    	source += "/";
    
    
    String targetParent = getParentPath(target);
    if (targetParent != null && targetParent.startsWith(source))
    {
    	if (Utils.doLog())
    		Log.d("KP2A_FC_P", source+" is parent of "+target);
        return BaseFileProviderUtils.newClosedCursor();
    }
    if (Utils.doLog())
		Log.d("KP2A_FC_P", source+" is no parent of "+target);

    return null;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:40,代码来源:Kp2aFileProvider.java


示例15: extractFile

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
/**
 * Extracts source file from request URI.
 * 
 * @param uri
 *            the original URI.
 * @return the filename.
 */
private static String extractFile(Uri uri) {
    String fileName = Uri.parse(uri.getLastPathSegment()).toString();
    if (uri.getQueryParameter(BaseFile.PARAM_APPEND_PATH) != null)
        fileName += Uri.parse(
                uri.getQueryParameter(BaseFile.PARAM_APPEND_PATH)).toString();
    if (uri.getQueryParameter(BaseFile.PARAM_APPEND_NAME) != null)
        fileName += "/" + uri.getQueryParameter(BaseFile.PARAM_APPEND_NAME);

    if (Utils.doLog())
        Log.d(CLASSNAME, "extractFile() >> " + fileName);

    return fileName;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:21,代码来源:Kp2aFileProvider.java


示例16: delete

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
    if (Utils.doLog())
        Log.d(CLASSNAME, "delete() >> " + uri);

    int count = 0;

    switch (URI_MATCHER.match(uri)) {
    case URI_FILE: {
        int taskId = ProviderUtils.getIntQueryParam(uri,
                BaseFile.PARAM_TASK_ID, 0);

        boolean isRecursive = ProviderUtils.getBooleanQueryParam(uri,
                BaseFile.PARAM_RECURSIVE, true);
        File file = extractFile(uri);
        if (file.canWrite()) {
            File parentFile = file.getParentFile();

            if (file.isFile() || !isRecursive) {
                if (file.delete())
                    count = 1;
            } else {
                mMapInterruption.put(taskId, false);
                count = deleteFile(taskId, file, isRecursive);
                if (mMapInterruption.get(taskId))
                    if (Utils.doLog())
                        Log.d(CLASSNAME, "delete() >> cancelled...");
                mMapInterruption.delete(taskId);
            }

            if (count > 0) {
                getContext()
                        .getContentResolver()
                        .notifyChange(
                                BaseFile.genContentUriBase(
                                        LocalFileContract
                                                .getAuthority(getContext()))
                                        .buildUpon()
                                        .appendPath(
                                                Uri.fromFile(parentFile)
                                                        .toString())
                                        .build(), null);
            }
        }

        break;// URI_FILE
    }

    default:
        throw new IllegalArgumentException("UNKNOWN URI " + uri);
    }

    if (Utils.doLog())
        Log.d(CLASSNAME, "delete() >> count = " + count);

    if (count > 0)
        getContext().getContentResolver().notifyChange(uri, null);

    return count;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:61,代码来源:LocalFileProvider.java


示例17: insert

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public Uri insert(Uri uri, ContentValues values) {
    if (Utils.doLog())
        Log.d(CLASSNAME, "insert() >> " + uri);

    switch (URI_MATCHER.match(uri)) {
    case URI_DIRECTORY:
        File file = extractFile(uri);
        if (!file.isDirectory() || !file.canWrite())
            return null;

        File newFile = new File(String.format("%s/%s",
                file.getAbsolutePath(),
                uri.getQueryParameter(BaseFile.PARAM_NAME)));

        switch (ProviderUtils.getIntQueryParam(uri,
                BaseFile.PARAM_FILE_TYPE, BaseFile.FILE_TYPE_DIRECTORY)) {
        case BaseFile.FILE_TYPE_DIRECTORY:
            newFile.mkdir();
            break;// FILE_TYPE_DIRECTORY

        case BaseFile.FILE_TYPE_FILE:
            try {
                newFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
            break;// FILE_TYPE_FILE

        default:
            return null;
        }

        if (newFile.exists()) {
            Uri newUri = BaseFile
                    .genContentIdUriBase(
                            LocalFileContract.getAuthority(getContext()))
                    .buildUpon()
                    .appendPath(Uri.fromFile(newFile).toString()).build();
            getContext().getContentResolver().notifyChange(uri, null);
            return newUri;
        }
        return null;// URI_FILE

    default:
        throw new IllegalArgumentException("UNKNOWN URI " + uri);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:49,代码来源:LocalFileProvider.java


示例18: listFiles

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
/**
 * Lists all file inside {@code dir}.
 * 
 * @param taskId
 *            the task ID.
 * @param dir
 *            the source directory.
 * @param showHiddenFiles
 *            {@code true} or {@code false}.
 * @param filterMode
 *            can be one of {@link BaseFile#FILTER_DIRECTORIES_ONLY},
 *            {@link BaseFile#FILTER_FILES_ONLY},
 *            {@link BaseFile#FILTER_FILES_AND_DIRECTORIES}.
 * @param limit
 *            the limit.
 * @param positiveRegex
 *            the positive regex filter.
 * @param negativeRegex
 *            the negative regex filter.
 * @param results
 *            the results.
 * @param hasMoreFiles
 *            the first item will contain a value representing that there is
 *            more files (exceeding {@code limit}) or not.
 */
private void listFiles(final int taskId, final File dir,
        final boolean showHiddenFiles, final int filterMode,
        final int limit, String positiveRegex, String negativeRegex,
        final List<File> results, final boolean hasMoreFiles[]) {
    final Pattern positivePattern = Texts.compileRegex(positiveRegex);
    final Pattern negativePattern = Texts.compileRegex(negativeRegex);

    hasMoreFiles[0] = false;
    try {
        dir.listFiles(new FileFilter() {

            @Override
            public boolean accept(File pathname) {
                if (mMapInterruption.get(taskId))
                    throw new CancellationException();

                final boolean isFile = pathname.isFile();
                final String name = pathname.getName();

                /*
                 * Filters...
                 */
                if (filterMode == BaseFile.FILTER_DIRECTORIES_ONLY
                        && isFile)
                    return false;
                if (!showHiddenFiles && name.startsWith("."))
                    return false;
                if (isFile && positivePattern != null
                        && !positivePattern.matcher(name).find())
                    return false;
                if (isFile && negativePattern != null
                        && negativePattern.matcher(name).find())
                    return false;

                /*
                 * Limit...
                 */
                if (results.size() >= limit) {
                    hasMoreFiles[0] = true;
                    throw new CancellationException("Exceeding limit...");
                }
                results.add(pathname);

                return false;
            }// accept()
        });
    } catch (CancellationException e) {
        if (Utils.doLog())
            Log.d(CLASSNAME, "listFiles() >> cancelled... >> " + e);
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:77,代码来源:LocalFileProvider.java


示例19: sortFiles

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
/**
 * Sorts {@code files}.
 * 
 * @param taskId
 *            the task ID.
 * @param files
 *            list of files.
 * @param ascending
 *            {@code true} or {@code false}.
 * @param sortBy
 *            can be one of {@link BaseFile.#_SortByModificationTime},
 *            {@link BaseFile.#_SortByName}, {@link BaseFile.#_SortBySize}.
 */
private void sortFiles(final int taskId, final List<File> files,
        final boolean ascending, final int sortBy) {
    try {
        Collections.sort(files, new Comparator<File>() {

            @Override
            public int compare(File lhs, File rhs) {
                if (mMapInterruption.get(taskId))
                    throw new CancellationException();

                if (lhs.isDirectory() && !rhs.isDirectory())
                    return -1;
                if (!lhs.isDirectory() && rhs.isDirectory())
                    return 1;

                /*
                 * Default is to compare by name (case insensitive).
                 */
                int res = mCollator.compare(lhs.getName(), rhs.getName());

                switch (sortBy) {
                case BaseFile.SORT_BY_NAME:
                    break;// SortByName

                case BaseFile.SORT_BY_SIZE:
                    if (lhs.length() > rhs.length())
                        res = 1;
                    else if (lhs.length() < rhs.length())
                        res = -1;
                    break;// SortBySize

                case BaseFile.SORT_BY_MODIFICATION_TIME:
                    if (lhs.lastModified() > rhs.lastModified())
                        res = 1;
                    else if (lhs.lastModified() < rhs.lastModified())
                        res = -1;
                    break;// SortByDate
                }

                return ascending ? res : -res;
            }// compare()
        });
    } catch (CancellationException e) {
        if (Utils.doLog())
            Log.d(CLASSNAME, "sortFiles() >> cancelled...");
    }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:61,代码来源:LocalFileProvider.java


示例20: query

import group.pals.android.lib.ui.filechooser.utils.Utils; //导入依赖的package包/类
@Override
public synchronized Cursor query(Uri uri, String[] projection,
        String selection, String[] selectionArgs, String sortOrder) {
    if (Utils.doLog())
        Log.d(CLASSNAME, String.format(
                "query() >> uri = %s, selection = %s, sortOrder = %s", uri,
                selection, sortOrder));

    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(HistoryContract.TABLE_NAME);
    qb.setProjectionMap(MAP_COLUMNS);

    SQLiteDatabase db = null;
    Cursor cursor = null;

    /*
     * Choose the projection and adjust the "where" clause based on URI
     * pattern-matching.
     */
    switch (URI_MATCHER.match(uri)) {
    case URI_HISTORY: {
        if (Arrays.equals(projection,
                new String[] { HistoryContract._COUNT })) {
            db = mHistoryHelper.getReadableDatabase();
            cursor = db.rawQuery(
                    String.format(
                            "SELECT COUNT(*) AS %s FROM %s %s",
                            HistoryContract._COUNT,
                            HistoryContract.TABLE_NAME,
                            selection != null ? String.format("WHERE %s",
                                    selection) : "").trim(), null);
        }

        break;
    }// URI_HISTORY

    /*
     * If the incoming URI is for a single history item identified by its
     * ID, chooses the history item ID projection, and appends
     * "_ID = <history-item-ID>" to the where clause, so that it selects
     * that single history item.
     */
    case URI_HISTORY_ID: {
        qb.appendWhere(DbUtils.SQLITE_FTS_COLUMN_ROW_ID + " = "
                + uri.getLastPathSegment());

        break;
    }// URI_HISTORY_ID

    default:
        throw new IllegalArgumentException("UNKNOWN URI " + uri);
    }

    if (TextUtils.isEmpty(sortOrder))
        sortOrder = HistoryContract.DEFAULT_SORT_ORDER;

    /*
     * Opens the database object in "read" mode, since no writes need to be
     * done.
     */
    if (Utils.doLog())
        Log.d(CLASSNAME,
                String.format("Going to SQLiteQueryBuilder >> db = %s", db));
    if (db == null) {
        db = mHistoryHelper.getReadableDatabase();
        /*
         * Performs the query. If no problems occur trying to read the
         * database, then a Cursor object is returned; otherwise, the cursor
         * variable contains null. If no records were selected, then the
         * Cursor object is empty, and Cursor.getCount() returns 0.
         */
        cursor = qb.query(db, projection, selection, selectionArgs, null,
                null, sortOrder);
    }

    cursor = appendNameAndRealUri(cursor);
    cursor.setNotificationUri(getContext().getContentResolver(), uri);
    return cursor;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:80,代码来源:HistoryProvider.java



注:本文中的group.pals.android.lib.ui.filechooser.utils.Utils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Tracer类代码示例发布时间:2022-05-22
下一篇:
Java User类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap