当前位置: 首页>>代码示例>>Java>>正文


Java Utils类代码示例

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


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

示例1: getParent

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
static private Uri getParent(Uri uri) {
      if (isOneOfTheRootStorageItems(uri)) {
	return VIRTUAL_ROOT_POINT;
} else {
          Uri parentUri = Utils.getParentUrl(uri);
          if (parentUri != null) {
              String parent = parentUri.toString();
              if (parent != null && !parent.isEmpty() && parent.endsWith("/")) {
                  int index = parent.lastIndexOf("/");
                  if (index > 0) {
                      parent = parent.substring(0, index);
                  }
              }
              return Uri.parse(parent);
          }
      }
      return VIRTUAL_ROOT_POINT;
  }
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:19,代码来源:FolderPicker.java

示例2: updateNowPlayingMetadata

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
/**
 * Update title and pic on now playing card
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void updateNowPlayingMetadata() {
    MediaMetadata.Builder metadataBuilder = new MediaMetadata.Builder();
    String title = mVideoInfo.scraperTitle!=null?mVideoInfo.scraperTitle:mVideoInfo.title!=null?mVideoInfo.title:Utils.getFileNameWithoutExtension(mUri);
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_TITLE,
            title);
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_TITLE,title);
    metadataBuilder.putString(MediaMetadata.METADATA_KEY_DISPLAY_ICON_URI,
            mVideoInfo.scraperCover);
    Bitmap bitmap = BitmapFactory.decodeFile(mVideoInfo.scraperCover);
    if (bitmap == null&&mVideoInfo.id >= 0) { //if no scrapped poster, try to get a thumbnail
        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inSampleSize = 2;
        bitmap = VideoStore.Video.Thumbnails.getThumbnail(getContentResolver(),mVideoInfo.id, VideoStore.Video.Thumbnails.MINI_KIND, options);
    }
    if (bitmap == null) {
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.widget_default_video);
    }
    metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap);
    mSession.setMetadata(metadataBuilder.build());
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:25,代码来源:PlayerService.java

示例3: onOptionsItemSelected

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean ret;
    switch (item.getItemId()) {
        case R.string.add_to_indexed_folders:
            // Handle this item when it is in the options menu
            createShortcut(mCurrentDirectory.toString(), Utils.getName(mCurrentDirectory));
            ret = true;
            break;
        case R.string.remove_from_indexed_folders:
            removeShortcut(mCurrentDirectory.toString());
            ret = true;
            break;
        case R.string.manually_create_share:
            CreateShareDialog shareDialog = new CreateShareDialog();
            shareDialog.setRetainInstance(true); // the dialog is dismissed at screen rotation, that's better than a crash...
            shareDialog.show(getFragmentManager(), "CreateShareDialog");
        case R.string.rescan:
            NetworkScanner.scanVideos(mContext, mCurrentDirectory);
            return true;
        default:
            ret = super.onOptionsItemSelected(item);
            break;
    }
    return ret;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:27,代码来源:BrowserByNetwork.java

示例4: onContextItemSelected

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
	if(item.getItemId() ==  R.string.copy_on_device_multi){
		AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
		Tvshow tvshow = (Tvshow) mBrowserAdapter.getItem(info.position);
		ArrayList<Uri> list = new ArrayList<>();
		Cursor cursor2 = getEpisodeForShowCursor(tvshow.getTvshowId());
		if(cursor2!=null) {
			if (cursor2.getCount() > 0) {
				cursor2.moveToFirst();
				int uriCol = cursor2.getColumnIndex(VideoStore.MediaColumns.DATA);
				do {
					Uri uri = Uri.parse(cursor2.getString(uriCol));
					if (!Utils.isLocal(uri))
						list.add(uri);
				} while (cursor2.moveToNext());
				startDownloadingVideo(list);

			}
		}
		cursor2.close();
		return  true;
	}
	else return super.onContextItemSelected(item);

}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:27,代码来源:BrowserAllTvShows.java

示例5: onFileDelete

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
public void onFileDelete(Uri file) {

        if(file.toString().endsWith("/")&&!mUri.toString().endsWith("/")&&file.toString().equals(mUri.toString()+"/")|| mUri.equals(file)) { //if current listed uri
            if (isAdded()) getActivity().onBackPressed();
        }
        else{ //if parent uri
            Uri parent = Utils.getParentUrl(file);
            if(parent.toString().endsWith("/")&&!mUri.toString().endsWith("/")&&parent.toString().equals(mUri.toString()+"/") || mUri.equals(parent)){
                // we need to refresh
                if(isAdded())
                    startListing(mUri);
                else
                    mRefreshOnNextResume = true;
            }
        }
    }
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:17,代码来源:ListingFragment.java

示例6: writeXmlEntry

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
private static void writeXmlEntry(StringWriter writer, VideoDbInfo entry) {
    writer.append("<path>");
    escapeAndAppendString(Utils.getName(entry.uri), writer);
    writer.append("</path>\n");
    if (entry.resume == -2 || entry.resume >= 0)
        writeXmlEntryElement(writer, "last_position", Integer.toString(entry.resume));
    if (entry.bookmark >= 0)
        writeXmlEntryElement(writer, "bookmark_position", Integer.toString(entry.bookmark));
    if (entry.audioTrack >= 0)
        writeXmlEntryElement(writer, "audio_track", Integer.toString(entry.audioTrack));
    if (entry.subtitleTrack >= 0)
        writeXmlEntryElement(writer, "subtitle_track", Integer.toString(entry.subtitleTrack));
    if (entry.subtitleDelay != 0)
        writeXmlEntryElement(writer, "subtitle_delay", Integer.toString(entry.subtitleDelay));
    if (entry.subtitleRatio != 0)
        writeXmlEntryElement(writer, "subtitle_ratio", Integer.toString(entry.subtitleRatio));
            if (entry.lastTimePlayed >= 0)
        writeXmlEntryElement(writer, "last_time_played", Long.toString(entry.lastTimePlayed));
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:20,代码来源:XmlDb.java

示例7: requestIndexing

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
/**
 * set hidden false when reindex is true
 * */

public static void requestIndexing(Uri uri, Context context, boolean reIndex) {
    if (uri == null || context == null) {
        Log.w(TAG, "requestIndexing: file or context null");
        return;
    }
    //first check if video is hidden
    if(reIndex) {
        Uri tmp = uri;
        if ("file".equals(tmp.getScheme())) {
            tmp = Uri.parse(uri.toString().substring("file://".length()));
        }
        String whereR = VideoStore.MediaColumns.DATA + " = ?";
        final ContentValues cvR = new ContentValues(1);
        String col = VideoStore.Video.VideoColumns.ARCHOS_HIDDEN_BY_USER;
        cvR.put(col, 0);
        context.getContentResolver().update(VideoStore.Video.Media.EXTERNAL_CONTENT_URI, cvR, whereR, new String[]{tmp.toString()});
    }
    String action;
    if ((!Utils.isLocal(uri)||UriUtils.isContentUri(uri))&& UriUtils.isIndexable(uri)) {
        action = ArchosMediaIntent.ACTION_VIDEO_SCANNER_SCAN_FILE;
    }
    else {
        action = Intent.ACTION_MEDIA_SCANNER_SCAN_FILE;
        if(uri.getScheme()==null)
            uri = Uri.parse("file://"+uri.toString());
    }
    Intent scanIntent = new Intent(action);
    scanIntent.setData(uri);
    if(!UriUtils.isContentUri(uri)) // doesn't work with content
        context.sendBroadcast(scanIntent);
    else
        NetworkScannerServiceVideo.startIfHandles(context, scanIntent);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:38,代码来源:VideoStore.java

示例8: compressFile

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
public static boolean compressFile(File toCompress, File target) {
    if (target == null || toCompress == null) {
        return false;
    }
    try {
        final Uri uri = Uri.fromFile(toCompress);
        final String rootPath = Utils.getParentUrl(uri.toString());
        final int rootOffset = rootPath.length();

        ZipOutputStream zos = new ZipOutputStream(FileEditorFactory.getFileEditorForUrl(Uri.fromFile(target), null).getOutputStream());
        ZipEntry entry = new ZipEntry(uri.toString().substring(rootOffset));
        byte[] bytes = new byte[1024];
        InputStream fis = FileEditorFactory.getFileEditorForUrl(uri, null).getInputStream();
        entry.setSize(toCompress.length());
        entry.setTime(toCompress.lastModified());
        zos.putNextEntry(entry);
        int count;
        while ((count = fis.read(bytes)) > 0) {
            zos.write(bytes, 0, count);
        }
        zos.closeEntry();
        closeSilently(fis);
        closeSilently(zos);
        return true;
    }
    catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:31,代码来源:ZipUtils.java

示例9: getParentUriStringAndFileName

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
public static Pair<String, String>  getParentUriStringAndFileName(Uri uri){
    //try to get parent
    String last = uri.getLastPathSegment();
    String[] parts = last.split(":");
    int i = 0;
    String parentLastPart = "";
    String filename="";
    parentLastPart+=parts[0]+ Uri.encode(":");
    if(parts.length>1&&parts[1]!=null) {
        parts = parts[1].split("/");
        for (String part : parts) {
            i++;
            if (i != parts.length) {
                parentLastPart += Uri.encode(part);
                if (i != parts.length-1)
                    parentLastPart += Uri.encode("/");

            } else
                filename = part;
        }
    }
    else
        filename = parts[0] ;
    Uri withoutLastPath = Utils.removeLastSegment(uri);
    return new Pair<>(Uri.withAppendedPath(withoutLastPath, parentLastPart).toString(),filename);

}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:28,代码来源:DocumentUriBuilder.java

示例10: onReceive

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    NetworkState networkState = NetworkState.instance(context);
    networkState.updateFrom(context);
    if (mCurrentVideo!=null&&(!networkState.isConnected()||!networkState.hasLocalConnection()&&!Utils.isSlowRemote(mCurrentVideo.getFileUri()))&&!Utils.isLocal(mCurrentVideo.getFileUri())&&isAdded()&&!isDetached()) {
        getActivity().finish();
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:9,代码来源:VideoInfoActivityFragment.java

示例11: setSource

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
public void setSource(Uri source){
    if(source.equals(mSelectedUri)){
        ((CardView)mRootView).setCardBackgroundColor(mBackgroundColor);
    }
    else ((CardView)mRootView).setCardBackgroundColor(ContextCompat.getColor(mContext, R.color.transparent_grey));

    if(Utils.isLocal(source)){
        mSourceTextView.setText("Local");
    }
    else {
        mSourceTextView.setText(source.getScheme());
    }

}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:15,代码来源:VideoBadgePresenter.java

示例12: startStatusbarNotification

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
public void startStatusbarNotification(boolean isDicreteOrMinimized) {
    Intent notificationIntent = new Intent("DISPLAY_FLOATING_PLAYER");
    PendingIntent contentIntent = PendingIntent.getBroadcast(this, 0, notificationIntent, 0);
    mNotificationBuilder = new NotificationCompat.Builder(this);
    int icon = R.drawable.video2;
    mNotificationBuilder.setSmallIcon(icon);
    mNotificationBuilder.setTicker(null);
    mNotificationBuilder.setOnlyAlertOnce(true);
    String title = "";
    if(getVideoInfo()!=null&&PlayerService.sPlayerService.getVideoInfo().scraperTitle!=null&&!PlayerService.sPlayerService.getVideoInfo().scraperTitle.isEmpty())
        title = sPlayerService.getVideoInfo().scraperTitle;
    else if(getVideoInfo()!=null&&getVideoInfo().title!=null)
        title = getVideoInfo().title;
    else
        title = Utils.getFileNameWithoutExtension(mUri);
    mNotificationBuilder.setContentTitle(getString(R.string.now_playing));
    mNotificationBuilder.setContentText(title);
    mNotificationBuilder.setContentIntent(contentIntent);
    if(mPlayer!=null){
        if(mPlayer.isPlaying())
            mNotificationBuilder.addAction(new NotificationCompat.Action(R.drawable.video_pause, getString(R.string.floating_player_pause), PendingIntent.getBroadcast(this, 0, new Intent(PAUSE_INTENT),0)));
        else if(mPlayer.isInPlaybackState())
            mNotificationBuilder.addAction(new NotificationCompat.Action(R.drawable.video_play, getString(R.string.floating_player_play),  PendingIntent.getBroadcast(this, 0, new Intent(PLAY_INTENT),0)));

    }
    if(isDicreteOrMinimized)
        mNotificationBuilder.addAction(new NotificationCompat.Action(R.drawable.ic_menu_unfade, getString(R.string.floating_player_restore), contentIntent));
    else
        mNotificationBuilder.addAction(new NotificationCompat.Action(R.drawable.video_format_fullscreen, getString(R.string.format_fullscreen), PendingIntent.getBroadcast(this, 0, new Intent(FULLSCREEN_INTENT),0)));
    mNotificationBuilder.setDeleteIntent(PendingIntent.getBroadcast(this, 0, new Intent(EXIT_INTENT), 0));
    mNotificationBuilder.setOngoing(false);
    mNotificationBuilder.setDefaults(0);
    mNotificationBuilder.setAutoCancel(true);
    Notification notif = mNotificationBuilder.build();

    //notif.bigContentView = new RemoteViews(getPackageName(), R.layout.notification_controls);

    startForeground(PLAYER_NOTIFICATION_ID, notif);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:40,代码来源:PlayerService.java

示例13: getActionBarTitle

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
protected String getActionBarTitle() {
    if(mTitle!=null)
        return mTitle;
    if (mCurrentDirectory.equals(Uri.fromFile(Environment.getExternalStorageDirectory()))) {
        return  getResources().getString(R.string.root_storage);
    } else {
        return Utils.getName(mCurrentDirectory);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:10,代码来源:BrowserByFolder.java

示例14: createShortcut

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
private void createShortcut(String shortcutPath) {
    // Add the shortcut to the list
    ShortcutDbAdapter.Shortcut shortcut = new ShortcutDbAdapter.Shortcut(Utils.getName(Uri.parse(shortcutPath)),shortcutPath);
    ShortcutDbAdapter.VIDEO.addShortcut(getActivity(), shortcut);

    String text = getString(R.string.indexed_folder_added, shortcutPath);
    Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();

    // Send a scan request to MediaScanner
    NetworkScanner.scanVideos(getActivity(), shortcutPath);

    // Update the menu items
    getActivity().invalidateOptionsMenu();
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:15,代码来源:CreateShareDialog.java

示例15: deleteFileAndAssociatedFiles

import com.archos.filecorelibrary.Utils; //导入依赖的package包/类
public static boolean deleteFileAndAssociatedFiles(Context context, Uri fileUri) {
    // Get list of all files (video and associated)
    List<Uri> associatedFiles = getAssociatedFiles(fileUri);
    // Do not forget to add the video file!
    List<Uri> allFiles = new ArrayList<>(associatedFiles.size()+1);
    allFiles.add(fileUri);
    allFiles.addAll(associatedFiles);
    // Delete found associated files
    for (Uri uri : allFiles) {

        FileEditor editor = FileEditorFactory.getFileEditorForUrl(uri,context);
        try {
            if(editor instanceof LocalStorageFileEditor) //delete from database
                ((LocalStorageFileEditor)editor).deleteFileAndDatabase(context);
            else {
                NetworkScanner.removeVideos(context, uri);
                editor.delete();
            }
        } catch (Exception e) {
            Log.e(TAG, "Failed to delete file " + uri, e);
            if(uri == fileUri) // if failure is on main file
                return false;
        }
    }
    //delete subs
    if(!Utils.isSlowRemote(fileUri)) {
        SubtitleManager.deleteAssociatedSubs(fileUri,context);
        XmlDb.deleteAssociatedResumeDatabase(fileUri);
    }
    return true;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:32,代码来源:Delete.java


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