Example usage for java.lang IllegalStateException printStackTrace

List of usage examples for java.lang IllegalStateException printStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalStateException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.czh.testmpeg.videorecord.CameraActivity.java

private boolean prepareMediaRecorder() {
    mediaRecorder = new MediaRecorder();
    mCamera.unlock();/*from  w  ww .  j a v a2 s . c  o  m*/
    mediaRecorder.setCamera(mCamera);
    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
        if (cameraFront) {
            mediaRecorder.setOrientationHint(270);
        } else {
            mediaRecorder.setOrientationHint(90);
        }
    }

    mediaRecorder.setProfile(CamcorderProfile.get(quality));
    File file = new File("/mnt/sdcard/videokit");
    if (!file.exists()) {
        file.mkdirs();
    }
    Date d = new Date();
    String timestamp = String.valueOf(d.getTime());
    //        url_file = Environment.getExternalStorageDirectory().getPath() + "/videoKit" + timestamp + ".mp4";
    url_file = "/mnt/sdcard/videokit/in.mp4";
    //        url_file = "/mnt/sdcard/videokit/" + timestamp + ".mp4";

    File file1 = new File(url_file);
    if (file1.exists()) {
        file1.delete();
    }

    mediaRecorder.setOutputFile(url_file);

    //        https://developer.android.com/reference/android/media/MediaRecorder.html#setMaxDuration(int) ??
    //        mediaRecorder.setMaxDuration(CameraConfig.MAX_DURATION_RECORD); // 60s.
    //        https://developer.android.com/reference/android/media/MediaRecorder.html#setMaxFileSize(int) ??
    //        mediaRecorder.setMaxFileSize(CameraConfig.MAX_FILE_SIZE_RECORD); //size 1G

    try {
        mediaRecorder.prepare();
    } catch (IllegalStateException e) {
        e.printStackTrace();
        releaseMediaRecorder();
        return false;
    } catch (IOException e) {
        e.printStackTrace();
        releaseMediaRecorder();
        return false;
    }
    return true;

}

From source file:net.kevxu.purdueassist.course.ScheduleDetail.java

@Override
public void onRequestFinished(HttpResponse httpResponse) {
    try {//from w  w  w . j ava2  s.com
        InputStream stream = httpResponse.getEntity().getContent();
        Header encoding = httpResponse.getEntity().getContentEncoding();
        Document document;
        if (encoding == null) {
            document = Jsoup.parse(stream, null, URL_HEAD);
        } else {
            document = Jsoup.parse(stream, encoding.getValue(), URL_HEAD);
        }
        stream.close();
        ScheduleDetailEntry entry = parseDocument(document);
        mListener.onScheduleDetailFinished(entry);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        mListener.onScheduleDetailFinished(e);
    } catch (HtmlParseException e) {
        mListener.onScheduleDetailFinished(e);
    } catch (CourseNotFoundException e) {
        mListener.onScheduleDetailFinished(e, term, crn);
    } catch (ResultNotMatchException e) {
        mListener.onScheduleDetailFinished(new HtmlParseException(e.getMessage()));
    } catch (Exception e) {
        mListener.onScheduleDetailFinished(e);
    } finally {
        this.requestFinished = true;
    }
}

From source file:it.geosolutions.opensdi.operations.FileBrowserOperationController.java

/**
 * Shows the list of files inside the selected folder after a file upload
 * //from   w ww.j  a  v a 2  s. c  o m
 * @param model
 * @return
 */
// @RequestMapping(value = "/files", method = RequestMethod.POST)
public String saveFileAndList(@ModelAttribute("uploadFile") FileUpload uploadFile, ModelMap model) {

    List<MultipartFile> files = uploadFile.getFiles();

    List<String> fileNames = new ArrayList<String>();

    HashMap<String, List<Operation>> availableOperations = getAvailableOperations();

    if (null != files && files.size() > 0) {
        for (MultipartFile multipartFile : files) {

            String fileName = multipartFile.getOriginalFilename();
            if (!"".equalsIgnoreCase(fileName)) {
                // Handle file content - multipartFile.getInputStream()
                try {
                    multipartFile.transferTo(new File(getRunTimeDir() + fileName));
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                fileNames.add(fileName);
            }
            LOGGER.debug(fileName);

        }
    }

    model.addAttribute("uploadedFiles", fileNames);
    model.addAttribute("accept", accept);
    FileBrowser fb = null;
    if (Boolean.TRUE.equals(this.showRunInformation)) {
        fb = new ExtendedFileBrowser();
        ((ExtendedFileBrowser) fb).setAvailableOperations(availableOperations);
        ((ExtendedFileBrowser) fb).setGeoBatchClient(geoBatchClient);
    } else {
        fb = new FileBrowser();
    }
    fb.setBaseDir(getRunTimeDir());
    fb.setRegex(fileRegex);
    fb.setScanDiretories(canNavigate);
    model.addAttribute("fileBrowser", fb);
    model.addAttribute("showRunInformation", showRunInformation);

    model.addAttribute("operations", availableOperations);

    model.addAttribute("context", operationJSP);
    ControllerUtils.setCommonModel(model);

    return "template";

}

From source file:it.drwolf.ridire.index.cwb.scripts.VRTFilesBuilder.java

@SuppressWarnings("unchecked")
@Asynchronous/*from  ww  w .  j a  v a2 s  .c  o  m*/
public void retagFiles(VRTFilesBuilderData vrtFilesBuilderData) {
    String destDir = vrtFilesBuilderData.getDestDir();
    StrTokenizer strTokenizer = new StrTokenizer("\t");
    this.ridirePlainTextCleaner = new RIDIREPlainTextCleaner(null);
    this.ridireReTagger = new RIDIREReTagger(null);
    this.entityManager = (EntityManager) Component.getInstance("entityManager");
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    try {
        this.userTx.setTransactionTimeout(1000 * 10 * 60);
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        String treeTaggerBin = this.entityManager
                .find(CommandParameter.class, CommandParameter.TREETAGGER_EXECUTABLE_KEY).getCommandValue();
        this.ridireReTagger.setTreetaggerBin(treeTaggerBin);
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();

        String strangeFilesList = vrtFilesBuilderData.getOrigDir();
        File strangeFilesListFile = new File(strangeFilesList);
        if (strangeFilesListFile.exists() && strangeFilesListFile.canRead()) {
            List<String> posFilesName = FileUtils.readLines(strangeFilesListFile);
            int count = 0;
            int size = posFilesName.size();
            for (String posFName : posFilesName) {
                String digest = FilenameUtils.getBaseName(posFName.trim()).replaceAll(".txt", "");
                if (this.vrtFileExists(destDir, digest)) {
                    System.out.println("Skipping: " + digest);
                    continue;
                }
                if (!this.userTx.isActive()) {
                    this.userTx.begin();
                }
                this.entityManager.joinTransaction();
                List<CrawledResource> crs = this.entityManager
                        .createQuery("from CrawledResource cr where cr.digest=:digest")
                        .setParameter("digest", digest).getResultList();
                if (crs != null && crs.size() > 0) {
                    CrawledResource cr = crs.get(0);
                    File fToBeCleaned = new File(posFName.trim().replace(".pos", ""));
                    try {
                        this.ridirePlainTextCleaner.cleanTextFile(fToBeCleaned);
                        this.ridireReTagger.retagFile(fToBeCleaned);
                        if (fToBeCleaned != null) {
                            Integer wordsNumber = Mapper
                                    .countWordsFromPoSTagResource(fToBeCleaned.getAbsolutePath());
                            cr.setWordsNumber(wordsNumber);
                            this.entityManager.persist(cr);
                            this.createVRTFile(posFName.trim(), strTokenizer, cr, new File(destDir));
                        }
                    } catch (ExecuteException ee) {
                        ee.printStackTrace();
                    }
                }
                this.entityManager.flush();
                this.entityManager.clear();
                this.userTx.commit();
                ++count;
                if (count % 100 == 0) {
                    System.out.println("Retagging: " + count + " of " + size);
                }
            }
        }
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (this.userTx != null && this.userTx.isActive()) {
                this.userTx.rollback();
            }
        } catch (IllegalStateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
    System.out.println("Retagging done.");
}

From source file:com.example.anna_maria.myapplication.Camera2VideoFragment.java

private void startRecordingVideo() {
    try {/*from  ww  w .  ja v  a2s  .c  o  m*/
        // UI
        mButtonVideo.setText(R.string.stop);
        mIsRecordingVideo = true;

        // Start recording
        mMediaRecorder.start();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:fm.krui.kruifm.StreamService.java

/**
 * Prepares the player for streaming and plays the audio upon completion.
 *//* w w w  .  j a v  a2 s .  com*/
private void prepareAudio() {
    try {
        Log.v(TAG, "Attempting to play stream from " + streamUrl);
        mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {

            @Override
            public void onPrepared(MediaPlayer mp) {

                // When the stream is buffered, kill prompt and start playing automatically.
                mp.start();
                isPrepared = true;

                // Clear cached track information and start audio service.
                setCurrentTrackInfo("", "", "");
                updateNotification("", "", true);
                setUpdateTimer(true);

                // Since we're not buffering anymore, hide the status bar from the user
                broadcastMessage(BROADCAST_COMMAND_STATUS_HIDE);
                Log.i(TAG, "Stream playback started.");

            }
        });

        // Prepares stream without blocking UI Thread
        mp.prepareAsync();
        updateStreamStatus(getString(R.string.stream_status_buffering), true);

    } catch (IllegalStateException e) {
        Log.e(TAG, "Caught IllegalStateException when preparing: ");
        e.printStackTrace();
    }
}

From source file:com.jogden.spunkycharts.pricebyvolumechart.PriceByVolumeChartFragmentAdapter.java

public void axisRefresh() {
    try {//  w  w w.  j a  va 2  s. co m
        _guiThrdHndlr.post(new Runnable() {
            public void run() {
                _volumeAxis.invalidate();
            }
        });
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:de.mdxdave.materialbreadcrumbsnavigation.MaterialBreadcrumbsNavigation.java

public void setActive(int child, boolean scrollTo, boolean clicked) {
    if (child > list.size()) {
        throw new IndexOutOfBoundsException(
                "There are only " + list.size() + " items, you can not call the " + child + " one");
    }/*from   w ww.  ja v a  2  s  . co m*/
    this.active = child;

    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        Log.i("view", String.valueOf(i));
        ((TextView) viewGroup.getChildAt(i).findViewById(R.id.breadcrumbnav_textView))
                .setTextColor(darkenColor(textColor));
    }

    try {
        final View v = viewGroup.getChildAt(child);
        TextView tv = (TextView) v.findViewById(R.id.breadcrumbnav_textView);
        tv.setTextColor(textColor);

        if (scrollTo)
            horizontalScrollView.post(new Runnable() {
                @Override
                public void run() {
                    horizontalScrollView.scrollTo(v.getLeft(), 0);
                }
            });

        NavigationItem item = list.get(child);
        if (item.getFragment() != null) {
            Fragment fragment = item.getFragment();
            Bundle bn = fragment.getArguments();
            if (bn == null) {
                bn = new Bundle();
            }
            bn.putInt("materialBreadcrumbsPosition", child - 1);
            try {
                fragment.setArguments(bn);
            } catch (IllegalStateException e) {
                // Fragment already active...
            }
            fragmentManager.beginTransaction().replace(fragmentLayout, fragment).commit();
        } else if (item.getObject() != null && clicked) {
            this.breadcrumbClickListener.onClick(item);
        }
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

}

From source file:org.schabi.newpipe.VideoItemListFragment.java

private void updateList(List<StreamPreviewInfo> list) {
    try {//  w  ww. j ava2s  . c om
        videoListAdapter.addVideoList(list);
        terminateThreads();
    } catch (java.lang.IllegalStateException e) {
        Toast.makeText(getActivity(), "Trying to set value while activity doesn't exist anymore.",
                Toast.LENGTH_SHORT).show();
        Log.w(TAG, "Trying to set value while activity doesn't exist anymore.");
    } catch (Exception e) {
        Toast.makeText(getActivity(), getString(R.string.general_error), Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    } finally {
        loadingNextPage = false;
    }
}

From source file:edu.sfsu.csc780.chathub.ui.MainActivity.java

private void startRecording() {
    recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(output_formats[currentFormat]);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    audioUri = getFilename();/*from w  w  w . j a  va2  s. c  o  m*/
    recorder.setOutputFile(audioUri);
    recorder.setOnErrorListener(errorListener);
    recorder.setOnInfoListener(infoListener);

    try {
        recorder.prepare();
        recorder.start();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}