Search in sources :

Example 11 with Vector

use of java.util.Vector in project NewPipe by TeamNewPipe.

the class VideoItemDetailFragment method updateInfo.

private void updateInfo(final StreamInfo info) {
    Activity a = getActivity();
    RelativeLayout textContentLayout = (RelativeLayout) activity.findViewById(R.id.detail_text_content_layout);
    final TextView videoTitleView = (TextView) activity.findViewById(R.id.detail_video_title_view);
    TextView uploaderView = (TextView) activity.findViewById(R.id.detail_uploader_view);
    TextView viewCountView = (TextView) activity.findViewById(R.id.detail_view_count_view);
    TextView thumbsUpView = (TextView) activity.findViewById(R.id.detail_thumbs_up_count_view);
    TextView thumbsDownView = (TextView) activity.findViewById(R.id.detail_thumbs_down_count_view);
    TextView uploadDateView = (TextView) activity.findViewById(R.id.detail_upload_date_view);
    TextView descriptionView = (TextView) activity.findViewById(R.id.detail_description_view);
    RecyclerView nextStreamView = (RecyclerView) activity.findViewById(R.id.detail_next_stream_content);
    RelativeLayout nextVideoRootFrame = (RelativeLayout) activity.findViewById(R.id.detail_next_stream_root_layout);
    TextView similarTitle = (TextView) activity.findViewById(R.id.detail_similar_title);
    Button backgroundButton = (Button) activity.findViewById(R.id.detail_stream_thumbnail_window_background_button);
    View thumbnailView = activity.findViewById(R.id.detail_thumbnail_view);
    View topView = activity.findViewById(R.id.detailTopView);
    Button channelButton = (Button) activity.findViewById(R.id.channel_button);
    // prevents a crash if the activity/fragment was already left when the response came
    if (channelButton != null) {
        progressBar.setVisibility(View.GONE);
        if (info.next_video != null) {
            // todo: activate this function or remove it
            nextStreamView.setVisibility(View.GONE);
        } else {
            nextStreamView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
        }
        textContentLayout.setVisibility(View.VISIBLE);
        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setVisibility(View.VISIBLE);
        } else {
            ImageView playArrowView = (ImageView) activity.findViewById(R.id.play_arrow_view);
            playArrowView.setVisibility(View.VISIBLE);
        }
        if (!showNextStreamItem) {
            nextVideoRootFrame.setVisibility(View.GONE);
            similarTitle.setVisibility(View.GONE);
        }
        videoTitleView.setText(info.title);
        topView.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == android.view.MotionEvent.ACTION_UP) {
                    ImageView arrow = (ImageView) activity.findViewById(R.id.toggle_description_view);
                    View extra = activity.findViewById(R.id.detailExtraView);
                    if (extra.getVisibility() == View.VISIBLE) {
                        extra.setVisibility(View.GONE);
                        arrow.setImageResource(R.drawable.arrow_down);
                    } else {
                        extra.setVisibility(View.VISIBLE);
                        arrow.setImageResource(R.drawable.arrow_up);
                    }
                }
                return true;
            }
        });
        // Since newpipe is designed to work even if certain information is not available,
        // the UI has to react on missing information.
        videoTitleView.setText(info.title);
        if (!info.uploader.isEmpty()) {
            uploaderView.setText(info.uploader);
        } else {
            activity.findViewById(R.id.detail_uploader_view).setVisibility(View.GONE);
        }
        if (info.view_count >= 0) {
            viewCountView.setText(Localization.localizeViewCount(info.view_count, a));
        } else {
            viewCountView.setVisibility(View.GONE);
        }
        if (info.dislike_count >= 0) {
            thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, a));
        } else {
            thumbsDownView.setVisibility(View.INVISIBLE);
            activity.findViewById(R.id.detail_thumbs_down_count_view).setVisibility(View.GONE);
        }
        if (info.like_count >= 0) {
            thumbsUpView.setText(Localization.localizeNumber(info.like_count, a));
        } else {
            thumbsUpView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_thumbs_up_img_view).setVisibility(View.GONE);
            thumbsDownView.setVisibility(View.GONE);
            activity.findViewById(R.id.detail_thumbs_down_img_view).setVisibility(View.GONE);
        }
        if (!info.upload_date.isEmpty()) {
            uploadDateView.setText(Localization.localizeDate(info.upload_date, a));
        } else {
            uploadDateView.setVisibility(View.GONE);
        }
        if (!info.description.isEmpty()) {
            descriptionView.setText(Html.fromHtml(info.description));
        } else {
            descriptionView.setVisibility(View.GONE);
        }
        descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
        // parse streams
        Vector<VideoStream> streamsToUse = new Vector<>();
        for (VideoStream i : info.video_streams) {
            if (useStream(i, streamsToUse)) {
                streamsToUse.add(i);
            }
        }
        textContentLayout.setVisibility(View.VISIBLE);
        if (info.next_video == null) {
            activity.findViewById(R.id.detail_next_stream_title).setVisibility(View.GONE);
        }
        if (info.related_streams != null && !info.related_streams.isEmpty()) {
            initSimilarVideos(info);
        } else {
            activity.findViewById(R.id.detail_similar_title).setVisibility(View.GONE);
            activity.findViewById(R.id.similar_streams_view).setVisibility(View.GONE);
        }
        setupActionBarHandler(info);
        if (autoPlayEnabled) {
            playVideo(info);
        }
        if (android.os.Build.VERSION.SDK_INT < 18) {
            playVideoButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    playVideo(info);
                }
            });
        }
        backgroundButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                playVideo(info);
            }
        });
        //todo: make backgroundButton handle this
        thumbnailView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                playVideo(info);
            }
        });
        if (info.channel_url != null && info.channel_url != "") {
            channelButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    NavStack.getInstance().openChannelActivity(getActivity(), info.channel_url, info.service_id);
                }
            });
        } else {
            channelButton.setVisibility(Button.GONE);
        }
        initThumbnailViews(info);
    }
}
Also used : VideoStream(org.schabi.newpipe.extractor.stream_info.VideoStream) ReCaptchaActivity(org.schabi.newpipe.ReCaptchaActivity) ExoPlayerActivity(org.schabi.newpipe.player.ExoPlayerActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) PlayVideoActivity(org.schabi.newpipe.player.PlayVideoActivity) ErrorActivity(org.schabi.newpipe.report.ErrorActivity) Activity(android.app.Activity) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) MotionEvent(android.view.MotionEvent) Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) Vector(java.util.Vector)

Example 12 with Vector

use of java.util.Vector in project pinpoint by naver.

the class DefaultServerMetaDataHolderTest method testRaceConditionWhenAddingAndInteratingServiceInfo.

@Test
public void testRaceConditionWhenAddingAndInteratingServiceInfo() throws InterruptedException {
    // Given
    final CountDownLatch initLatch = new CountDownLatch(THREAD_COUNT);
    final CountDownLatch startLatch = new CountDownLatch(1);
    final CountDownLatch endLatch = new CountDownLatch(THREAD_COUNT);
    final Queue<Throwable> exceptions = new ConcurrentLinkedQueue<Throwable>();
    final TestableServerMetaDataListener listener = new TestableServerMetaDataListener();
    final ServerMetaDataHolder metaDataContext = new DefaultServerMetaDataHolder(VM_ARGS);
    metaDataContext.addListener(listener);
    metaDataContext.setServerName(SERVER_INFO);
    // When
    final List<ServerMetaData> serverMetaDatas = new Vector<ServerMetaData>(THREAD_COUNT / 2);
    for (int i = 0; i < THREAD_COUNT; ++i) {
        if (i % 2 == 0) {
            final String serviceName = "/name" + i;
            final List<String> serviceLibs = new ArrayList<String>();
            executorService.submit(new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    initLatch.countDown();
                    try {
                        startLatch.await();
                        metaDataContext.addServiceInfo(serviceName, serviceLibs);
                        metaDataContext.notifyListeners();
                    } catch (Throwable t) {
                        exceptions.add(t);
                    } finally {
                        endLatch.countDown();
                    }
                    return null;
                }
            });
        } else {
            executorService.submit(new Callable<Void>() {

                @Override
                public Void call() throws Exception {
                    initLatch.countDown();
                    try {
                        startLatch.await();
                        ServerMetaData serverMetaData = listener.getServerMetaData();
                        serverMetaDatas.add(serverMetaData);
                    } catch (Throwable t) {
                        exceptions.add(t);
                    } finally {
                        endLatch.countDown();
                    }
                    return null;
                }
            });
        }
    }
    initLatch.await();
    startLatch.countDown();
    endLatch.await();
    // Then
    assertTrue("Failed with exceptions : " + exceptions, exceptions.isEmpty());
    ServerMetaData metaData = listener.getServerMetaData();
    assertEquals(metaData.getServerInfo(), SERVER_INFO);
    assertEquals(metaData.getVmArgs(), VM_ARGS);
    assertEquals(metaData.getServiceInfos().size(), THREAD_COUNT / 2);
    assertEquals(serverMetaDatas.size(), THREAD_COUNT / 2);
}
Also used : ArrayList(java.util.ArrayList) CountDownLatch(java.util.concurrent.CountDownLatch) ServerMetaDataHolder(com.navercorp.pinpoint.bootstrap.context.ServerMetaDataHolder) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Vector(java.util.Vector) ServerMetaData(com.navercorp.pinpoint.bootstrap.context.ServerMetaData) Test(org.junit.Test)

Example 13 with Vector

use of java.util.Vector in project android by owncloud.

the class FileDataStorageManager method getFolderContent.

private Vector<OCFile> getFolderContent(long parentId) /*, boolean onlyOnDevice*/
{
    Vector<OCFile> ret = new Vector<OCFile>();
    Uri req_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_DIR, String.valueOf(parentId));
    Cursor c = null;
    if (getContentProviderClient() != null) {
        try {
            c = getContentProviderClient().query(req_uri, null, ProviderTableMeta.FILE_PARENT + "=?", new String[] { String.valueOf(parentId) }, null);
        } catch (RemoteException e) {
            Log_OC.e(TAG, e.getMessage());
            return ret;
        }
    } else {
        c = getContentResolver().query(req_uri, null, ProviderTableMeta.FILE_PARENT + "=?", new String[] { String.valueOf(parentId) }, null);
    }
    if (c != null) {
        if (c.moveToFirst()) {
            do {
                OCFile child = createFileInstance(c);
                // TODO Enable when "On Device" is recovered ?
                // if (child.isFolder() || !onlyOnDevice || onlyOnDevice && child.isDown()){
                ret.add(child);
            // }
            } while (c.moveToNext());
        }
        c.close();
    }
    Collections.sort(ret);
    return ret;
}
Also used : Cursor(android.database.Cursor) RemoteException(android.os.RemoteException) Vector(java.util.Vector) Uri(android.net.Uri)

Example 14 with Vector

use of java.util.Vector in project android by owncloud.

the class SynchronizeFolderOperation method mergeRemoteFolder.

/**
     *  Synchronizes the data retrieved from the server about the contents of the target folder
     *  with the current data in the local database.
     *
     *  Grants that mFoldersToVisit is updated with fresh data after execution.
     *
     *  @param folderAndFiles   Remote folder and children files in folder
     */
private void mergeRemoteFolder(ArrayList<Object> folderAndFiles) throws OperationCancelledException {
    Log_OC.d(TAG, "Synchronizing " + mAccount.name + mRemotePath);
    FileDataStorageManager storageManager = getStorageManager();
    // parse data from remote folder
    OCFile updatedFolder = FileStorageUtils.createOCFileFrom((RemoteFile) folderAndFiles.get(0));
    // NOTE: updates ETag with remote value; that's INTENDED
    updatedFolder.copyLocalPropertiesFrom(mLocalFolder);
    Log_OC.d(TAG, "Remote folder " + mLocalFolder.getRemotePath() + " changed - starting update of local data ");
    List<OCFile> updatedFiles = new Vector<>(folderAndFiles.size() - 1);
    mFoldersToVisit = new Vector<>(folderAndFiles.size() - 1);
    mFilesToSyncContents.clear();
    if (mCancellationRequested.get()) {
        throw new OperationCancelledException();
    }
    // get current data about local contents of the folder to synchronize
    List<OCFile> localFiles = storageManager.getFolderContent(mLocalFolder);
    Map<String, OCFile> localFilesMap = new HashMap<>(localFiles.size());
    for (OCFile file : localFiles) {
        localFilesMap.put(file.getRemotePath(), file);
    }
    // loop to synchronize every child
    OCFile remoteFile, localFile, updatedLocalFile;
    RemoteFile r;
    int foldersToExpand = 0;
    for (int i = 1; i < folderAndFiles.size(); i++) {
        /// new OCFile instance with the data from the server
        r = (RemoteFile) folderAndFiles.get(i);
        remoteFile = FileStorageUtils.createOCFileFrom(r);
        /// new OCFile instance to merge fresh data from server with local state
        updatedLocalFile = FileStorageUtils.createOCFileFrom(r);
        /// retrieve local data for the read file
        localFile = localFilesMap.remove(remoteFile.getRemotePath());
        /// add to updatedFile data about LOCAL STATE (not existing in server)
        updatedLocalFile.setLastSyncDateForProperties(mCurrentSyncTime);
        if (localFile != null) {
            updatedLocalFile.copyLocalPropertiesFrom(localFile);
            // remote eTag will not be set unless file CONTENTS are synchronized
            updatedLocalFile.setEtag(localFile.getEtag());
            if (!updatedLocalFile.isFolder() && remoteFile.isImage() && remoteFile.getModificationTimestamp() != localFile.getModificationTimestamp()) {
                updatedLocalFile.setNeedsUpdateThumbnail(true);
            }
        } else {
            updatedLocalFile.setParentId(mLocalFolder.getFileId());
            // remote eTag will not be set unless file CONTENTS are synchronized
            updatedLocalFile.setEtag("");
            // new files need to check av-off status of parent folder!
            if (updatedFolder.isAvailableOffline()) {
                updatedLocalFile.setAvailableOfflineStatus(OCFile.AvailableOfflineStatus.AVAILABLE_OFFLINE_PARENT);
            }
        }
        /// check and fix, if needed, local storage path
        searchForLocalFileInDefaultPath(updatedLocalFile);
        /// prepare content synchronizations
        boolean serverUnchanged = addToSyncContents(updatedLocalFile, remoteFile);
        if (updatedLocalFile.isFolder() && !serverUnchanged) {
            foldersToExpand++;
        }
        updatedFiles.add(updatedLocalFile);
    }
    // save updated contents in local database
    if (foldersToExpand == 0) {
        updatedFolder.setTreeEtag(updatedFolder.getEtag());
    // TODO - propagate up
    }
    storageManager.saveFolder(updatedFolder, updatedFiles, localFilesMap.values());
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) HashMap(java.util.HashMap) OperationCancelledException(com.owncloud.android.lib.common.operations.OperationCancelledException) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager) Vector(java.util.Vector) RemoteFile(com.owncloud.android.lib.resources.files.RemoteFile)

Example 15 with Vector

use of java.util.Vector in project titanium-barcode by mwaylabs.

the class TitaniumBarcodeActivity method parseDecodeFormats.

private static Vector<BarcodeFormat> parseDecodeFormats(Intent intent) {
    String scanFormats = intent.getStringExtra(Intents.Scan.SCAN_FORMATS);
    if (scanFormats != null) {
        Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
        try {
            for (String format : COMMA_PATTERN.split(scanFormats)) {
                formats.add(BarcodeFormat.valueOf(format));
            }
        } catch (IllegalArgumentException iae) {
            // ignore it then
            Log.d(TAG, iae.toString());
        }
    }
    String decodeMode = intent.getStringExtra(Intents.Scan.MODE);
    if (decodeMode != null) {
        if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) {
            return PRODUCT_FORMATS;
        }
        if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) {
            return QR_CODE_FORMATS;
        }
        if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) {
            return ONE_D_FORMATS;
        }
    }
    return null;
}
Also used : BarcodeFormat(com.google.zxing.BarcodeFormat) BarcodeString(com.mwaysolutions.barcode.constants.BarcodeString) Vector(java.util.Vector)

Aggregations

Vector (java.util.Vector)3045 IOException (java.io.IOException)239 ArrayList (java.util.ArrayList)224 Test (org.junit.Test)182 Enumeration (java.util.Enumeration)174 Iterator (java.util.Iterator)173 Hashtable (java.util.Hashtable)170 File (java.io.File)159 List (java.util.List)143 HashMap (java.util.HashMap)128 ResultSet (java.sql.ResultSet)122 SQLException (java.sql.SQLException)95 Collection (java.util.Collection)87 PreparedStatement (java.sql.PreparedStatement)79 StringTokenizer (java.util.StringTokenizer)79 Statement (java.sql.Statement)60 Fault (com.sun.ts.lib.harness.EETest.Fault)54 HashSet (java.util.HashSet)54 Expression (cbit.vcell.parser.Expression)52 Map (java.util.Map)50