本文整理汇总了Java中group.pals.android.lib.ui.filechooser.utils.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于group.pals.android.lib.ui.filechooser.utils包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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()
};
}
示例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);
}
}
示例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());
}
示例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();
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}