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:es.babel.cdm.navigation.NavigationManager.java

/**
 * Process Clear backstack flag./*  ww w .  jav a  2  s  .  c o  m*/
 * <p/>
 * NavigationManager will clear the back stack before trying to add the next Fragment if
 * {@link #CLEAR_BACKSTACK CLEAR_BACKSTACK} flag is found
 *
 * @param flags Added flags to the Fragment configuration
 */
protected void processClearBackstack(int flags) {
    if ((flags & CLEAR_BACKSTACK) == CLEAR_BACKSTACK) {
        try {
            fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        } catch (IllegalStateException exception) {
            exception.printStackTrace();
        }
    }
}

From source file:com.sonymobile.android.media.testmediaplayer.filebrowsing.MediaBrowser.java

private void startMediaPlayer(String path, boolean useUri) {
    if (mMediaPlayer.getState() != MediaPlayer.State.IDLE) {
        mMainActivity.reset();/*from www.jav  a  2 s. c o  m*/
    }
    try {
        if (LOGS_ENABLED)
            Log.d(TAG, "Setting datasource to: " + path);
        if (useUri) {
            // Method not used until fixed in framework
            // mMediaPlayer.setDataSource(mContext,
            // MediaStore.Video.Media.getContentUri(path));
            mMediaPlayer.setDataSource(path);
        } else {
            mMediaPlayer.setDataSource(path);
        }
        mMediaPlayer.prepareAsync();
        mDrawerLayout.closeDrawer(Gravity.START);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.kalypso.ogc.gml.map.widgets.GetFeatureInfoWidget.java

private void initialize(final IMapPanel mapPanel) {
    try {/*  ww  w.j a v a2s .c  o m*/
        /* Get the theme property. */
        final String themeProperty = getParameter("getFeatureInfoProperty"); //$NON-NLS-1$

        /* Get the map model. */
        final IMapModell mapModel = mapPanel.getMapModell();
        if (!(mapModel instanceof GisTemplateMapModell))
            throw new IllegalStateException(Messages.getString("GetFeatureInfoWidget_14")); //$NON-NLS-1$

        /* Find the theme. */
        m_wmsTheme = findTheme((GisTemplateMapModell) mapModel, themeProperty);

        /* Repaint the map. */
        repaintMap();
    } catch (final IllegalStateException ex) {
        ex.printStackTrace();
        m_wmsTheme = null;
        repaintMap();
    }
}

From source file:com.prashantmaurice.shadowfaxhackandroid.RecordService.java

private void startRecording(Intent intent) {
    Log.d(Constants.TAG, "RecordService startRecording");
    boolean exception = false;
    recorder = new MediaRecorder();

    try {/*from w  ww . ja  va 2  s . c o  m*/
        recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_CALL);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        fileName = FileHelper.getFilename(phoneNumber);
        recorder.setOutputFile(fileName);

        OnErrorListener errorListener = new OnErrorListener() {
            public void onError(MediaRecorder arg0, int arg1, int arg2) {
                Log.e(Constants.TAG, "OnErrorListener " + arg1 + "," + arg2);
                terminateAndEraseFile();
            }
        };
        recorder.setOnErrorListener(errorListener);

        OnInfoListener infoListener = new OnInfoListener() {
            public void onInfo(MediaRecorder arg0, int arg1, int arg2) {
                Log.e(Constants.TAG, "OnInfoListener " + arg1 + "," + arg2);
                terminateAndEraseFile();
            }
        };
        recorder.setOnInfoListener(infoListener);

        recorder.prepare();
        // Sometimes prepare takes some time to complete
        Thread.sleep(2000);
        recorder.start();
        recording = true;
        Log.d(Constants.TAG, "RecordService recorderStarted");
    } catch (IllegalStateException e) {
        Log.e(Constants.TAG, "IllegalStateException");
        e.printStackTrace();
        exception = true;
    } catch (IOException e) {
        Log.e(Constants.TAG, "IOException");
        e.printStackTrace();
        exception = true;
    } catch (Exception e) {
        Log.e(Constants.TAG, "Exception");
        e.printStackTrace();
        exception = true;
    }

    if (exception) {
        terminateAndEraseFile();
    }

    if (recording) {
        Toast toast = Toast.makeText(this, this.getString(R.string.receiver_start_call), Toast.LENGTH_SHORT);
        toast.show();
    } else {
        Toast toast = Toast.makeText(this, this.getString(R.string.record_impossible), Toast.LENGTH_LONG);
        toast.show();
    }
}

From source file:com.inovex.zabbixmobile.adapters.BaseServicePagerAdapter.java

@Override
public void finishUpdate(ViewGroup container) {
    if (mFragmentManager == null)
        return;/*  ww w  . j  a  v a 2 s .  c o m*/
    if (mCurTransaction != null) {
        try {
            mCurTransaction.commitAllowingStateLoss();
            mCurTransaction = null;
            // Commenting out the following two lines fixes a
            // "Recursive entry to executePendingTransactions" exception
            // I don't know why and hope this doesn't break anything
            //            if (mFragmentManager != null)
            //               mFragmentManager.executePendingTransactions();
        } catch (IllegalStateException e) {
            // this exception is thrown if the activity has been destroyed
            // which unfortunately happens from time to time
            e.printStackTrace();
            mCurTransaction = null;
        }
    }
}

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

/**
 * Shows the list of files inside the selected folder after a file upload
 * @param model/*from   ww w .  j a  va2s.  c o m*/
 * @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>();

    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(getDefaultBaseDir() + fileName));
                } catch (IllegalStateException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                fileNames.add(fileName);
            }
            System.out.println(fileName);

        }
    }

    model.addAttribute("uploadedFiles", fileNames);

    FileBrowser fb = new FileBrowser();
    fb.setBaseDir(getDefaultBaseDir());
    fb.setRegex(null);
    fb.setScanDiretories(canNavigate);
    model.addAttribute("fileBrowser", fb);

    model.addAttribute("operations", getAvailableOperations());

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

    return "template";

}

From source file:de.incoherent.suseconferenceclient.app.ConferenceCacher.java

public long cacheConference(Conference conference, Database db) {

    //String url = conference.getUrl();
    String url = "https://conference.opensuse.org/osem/api/v1/conferences/gRNyOIsTbvCfJY5ENYovBA";
    String eventsUrl = url + "/events.json";
    String roomsUrl = url + "/rooms.json";
    String speakersUrl = url + "/speakers.json";
    String tracksUrl = url + "/tracks.json";
    String venueUrl = url + "/venue.json";
    Long returnVal = null;/*from www.  j ava  2  s  .c  o  m*/
    HashMap<String, Long> roomMap = new HashMap<String, Long>();
    HashMap<String, Long> trackMap = new HashMap<String, Long>();
    HashMap<String, Long> speakerMap = new HashMap<String, Long>();

    try {
        Log.d("SUSEConferences", "Venues: " + venueUrl);
        publishProgress("venues");
        JSONObject venueReply = HTTPWrapper.get(venueUrl);
        JSONObject venue = venueReply.getJSONObject("venue");
        String infoUrl = url + "/" + venue.getString("info_text");
        Log.d("Application Url", "INFO URL: " + infoUrl);
        String info = HTTPWrapper.getRawText(infoUrl);
        String venueName = venue.getString("name");
        String venueAddr = venue.getString("address");
        String offlineMap = "";
        String offlineMapBounds = "";
        if (venue.has("offline_map")) {
            offlineMap = venue.getString("offline_map");
            offlineMapBounds = venue.getString("offline_map_bounds");
        }

        long venueId = db.insertVenue(venue.getString("guid"), venueName, venueAddr, offlineMap,
                offlineMapBounds, info);
        JSONArray mapPoints = venue.getJSONArray("map_points");
        int mapLen = mapPoints.length();
        for (int i = 0; i < mapLen; i++) {
            JSONObject point = mapPoints.getJSONObject(i);
            String lat = point.getString("lat");
            String lon = point.getString("lon");
            String type = point.getString("type");
            String name = "Unknown Point";
            String addr = "Unknown Address";
            String desc = "";

            if (point.has("name")) {
                name = point.getString("name");
            }
            if (point.has("address")) {
                addr = point.getString("address");
            }
            if (point.has("description")) {
                desc = point.getString("description");
            }

            db.insertVenuePoint(venueId, lat, lon, type, name, addr, desc);
        }

        if (venue.has("map_polygons")) {
            JSONArray polygons = venue.getJSONArray("map_polygons");
            int polygonLen = polygons.length();
            for (int j = 0; j < polygonLen; j++) {
                JSONObject polygon = polygons.getJSONObject(j);
                String name = polygon.getString("name");
                String label = polygon.getString("label");
                String lineColorStr = polygon.getString("line_color");
                String fillColorStr = "#00000000";
                if (polygon.has("fill_color"))
                    fillColorStr = polygon.getString("fill_color");

                List<String> stringList = new ArrayList<String>();
                JSONArray points = polygon.getJSONArray("points");
                int pointsLen = points.length();
                for (int k = 0; k < pointsLen; k++) {
                    String newPoint = points.getString(k);
                    stringList.add(newPoint);
                }
                String joined = TextUtils.join(";", stringList);
                int lineColor = Color.parseColor(lineColorStr);
                int fillColor = Color.parseColor(fillColorStr);
                db.insertVenuePolygon(venueId, name, label, lineColor, fillColor, joined);
            }
        }

        db.setConferenceVenue(venueId, conference.getSqlId());

        Log.d("SUSEConferences", "Rooms");
        publishProgress("rooms");
        JSONObject roomsReply = HTTPWrapper.get(roomsUrl);
        Log.d("Rooms of the event", "ROOMS URL: " + roomsUrl);
        JSONArray rooms = roomsReply.getJSONArray("rooms");
        int roomsLen = rooms.length();
        for (int i = 0; i < roomsLen; i++) {
            JSONObject room = rooms.getJSONObject(i);
            String guid = room.getString("guid");
            Long roomId = db.insertRoom(guid, room.getString("name"), room.getString("description"), venueId);
            roomMap.put(guid, roomId);
        }
        Log.d("SUSEConferences", "Tracks");
        publishProgress("tracks");
        JSONObject tracksReply = HTTPWrapper.get(tracksUrl);
        Log.d("Event tracks", "Tracks: " + tracksUrl);
        JSONArray tracks = tracksReply.getJSONArray("tracks");
        int tracksLen = tracks.length();
        for (int i = 0; i < tracksLen; i++) {
            JSONObject track = tracks.getJSONObject(i);
            String guid = track.getString("guid");
            Long trackId = db.insertTrack(guid, track.getString("name"), track.getString("color"),
                    conference.getSqlId());
            trackMap.put(guid, trackId);
        }
        Log.d("SUSEConferences", "Speakers");
        publishProgress("speakers");
        JSONObject speakersReply = HTTPWrapper.get(speakersUrl);
        JSONArray speakers = speakersReply.getJSONArray("speakers");
        int speakersLen = speakers.length();
        for (int i = 0; i < speakersLen; i++) {
            JSONObject speaker = speakers.getJSONObject(i);
            String guid = speaker.getString("guid");
            Long speakerId = db.insertSpeaker(guid, speaker.getString("name"), speaker.getString("company"),
                    speaker.getString("biography"), "");
            speakerMap.put(guid, speakerId);

        }

        Log.d("SUSEConferences", "Events");
        publishProgress("events");
        JSONObject eventsReply = HTTPWrapper.get(eventsUrl);
        JSONArray events = eventsReply.getJSONArray("events");
        int eventsLen = events.length();
        for (int i = 0; i < eventsLen; i++) {
            JSONObject event = events.getJSONObject(i);
            String guid = event.getString("guid");
            String track = event.getString("track");
            Long trackId = trackMap.get(track);
            Long roomId = roomMap.get(event.getString("room"));
            if (track.equals("meta")) {
                // The "meta" track is used to insert information
                // into the schedule that automatically appears on "my schedule",
                // and also isn't clickable.
                db.insertEvent(guid, conference.getSqlId(), roomId.longValue(), trackId.longValue(),
                        event.getString("date"), event.getInt("length"), "", "", event.getString("title"), "",
                        "");
            } else {
                Long eventId = db.insertEvent(guid, conference.getSqlId(), roomId.longValue(),
                        trackId.longValue(), event.getString("date"), event.getInt("length"),
                        event.getString("type"), event.getString("language"), event.getString("title"),
                        event.getString("abstract"), "");

                JSONArray eventSpeakers = event.getJSONArray("speaker_ids");
                int eventSpeakersLen = eventSpeakers.length();
                for (int j = 0; j < eventSpeakersLen; j++) {
                    Long speakerId = speakerMap.get(eventSpeakers.getString(j));
                    if (speakerId != null)
                        db.insertEventSpeaker(speakerId, eventId);
                }
            }
        }
    } catch (IllegalStateException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (SocketException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (IOException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    } catch (JSONException e) {
        e.printStackTrace();
        mErrorMessage = e.getLocalizedMessage();
        returnVal = Long.valueOf(-1);
    }

    if (returnVal == null)
        returnVal = conference.getSqlId();
    return returnVal;
}

From source file:org.simbrain.plot.histogram.HistogramPanel.java

/**
 * Create the histogram panel based on the data.
 *//* w  ww. j  ava2 s  .co m*/
public void createHistogram() {
    try {
        if (this.getModel().getData() != null) {
            mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(),
                    PlotOrientation.VERTICAL, true, true, false);
            mainChart.setBackgroundPaint(UIManager.getColor("this.Background"));

            XYPlot plot = (XYPlot) mainChart.getPlot();
            plot.setForegroundAlpha(0.75F);
            // Sets y-axis ticks to integers.
            NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
            renderer.setDrawBarOutline(false);
            renderer.setShadowVisible(false);

            Iterator<ColoredDataSeries> series = model.getSeriesData().iterator();
            for (int i = 0; i < model.getData().size(); i++) {
                if (i < colorPallet.length) {
                    ColoredDataSeries s = series.next();
                    Color c = s.color;
                    if (c == null) {
                        c = assignColor();
                        s.color = c;
                    }
                    renderer.setSeriesPaint(i, c, true);
                }
            }

        } else {

            mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(),
                    PlotOrientation.VERTICAL, true, true, false);
            mainChart.setBackgroundPaint(UIManager.getColor("this.Background"));

        }

    } catch (IllegalArgumentException iaEx) {
        iaEx.printStackTrace();
        JOptionPane.showMessageDialog(null, iaEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (IllegalStateException isEx) {
        isEx.printStackTrace();
        JOptionPane.showMessageDialog(null, isEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
    mainPanel = new ChartPanel(mainChart);

}

From source file:com.starwood.anglerslong.MainActivity.java

/*****************************************************************************************
 * Creates a new fragment to be loaded/*w ww  .  j  a va2s .com*/
 *****************************************************************************************
 * @param newFrag New Fragment to switch to
 * @param fragTitle Title of the fragment actionbar
 *****************************************************************************************/
public void createFragment(Fragment newFrag, String fragTitle) {

    try {
        Bundle bundle = new Bundle();
        bundle.putString("type", fragTitle);
        newFrag.setArguments(bundle);
    } catch (IllegalStateException i) {
        Log.d("KENNY", "IllegalStateException: Fragment already active.");
        i.printStackTrace();
    }

    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.container, newFrag);
    transaction.addToBackStack(null);

    mFragment = newFrag;

    transaction.commit();
}

From source file:com.android.server.MaybeDatabaseHelper.java

String getAppDataFromDb(String column, String packagename) {
    if (packagename == null || column == null) {
        Log.i(DBTAG, "packagename or column is null");
        return null;
    }//w  ww  .ja  va2 s  .  c  o m
    if (column != DATA_COL && column != URL_COL) {
        Log.i(DBTAG, "Not an acceptable query column");
        return null;
    }

    synchronized (sAppTableLock) {
        String ret_data = null;
        Cursor cursor = null;
        try {
            cursor = sDatabase.query(APP_TABLE_NAME, null, PACKAGE_COL + "='" + packagename + "'", null, null,
                    null, null, null);
            if (cursor.moveToFirst()) {
                ret_data = new String(cursor.getString(cursor.getColumnIndex(column)));
            }

        } catch (IllegalStateException e) {
            Log.e(DBTAG, "getAppDataFromDB failed", e);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (cursor != null)
                cursor.close();
        }
        Log.i(DBTAG, "DB Query: return data:" + ret_data);
        return ret_data;
    }
}