List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:com.flyingcrop.ScreenCaptureFragment.java
private void get_Metrics() { final DisplayMetrics metrics = new DisplayMetrics(); Display display = getActivity().getWindowManager().getDefaultDisplay(); Method mGetRawH = null;//from w w w .j a v a 2s . c o m Method mGetRawW = null; try { // For JellyBean 4.2 (API 17) and onward if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { display.getRealMetrics(metrics); mWidth = metrics.widthPixels; mHeight = metrics.heightPixels; screen_width = mWidth; screen_height = mHeight; mScreenDensity = metrics.densityDpi; } else { mGetRawH = Display.class.getMethod("getRawHeight"); mGetRawW = Display.class.getMethod("getRawWidth"); try { mWidth = (Integer) mGetRawW.invoke(display); mHeight = (Integer) mGetRawH.invoke(display); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } catch (NoSuchMethodException e3) { e3.printStackTrace(); } Log.d("getMetrics", "Width " + mWidth); Log.d("getMetrics", "Height " + mHeight); //crop bitmap x_inicial = getActivity().getIntent().getFloatExtra("x_inicial", -1); y_inicial = getActivity().getIntent().getFloatExtra("y_inicial", -1); x_final = getActivity().getIntent().getFloatExtra("x_final", -1); y_final = getActivity().getIntent().getFloatExtra("y_final", -1); if (y_inicial < 0) y_inicial = 0; status_bar_height = getStatusBarHeight(); SharedPreferences settings = getActivity().getSharedPreferences("data", 0); int scale = settings.getInt("scale", 1); switch (scale) { case 0: // low mWidth *= 0.25; mHeight *= 0.25; x_inicial *= 0.25; x_final *= 0.25; y_inicial *= 0.25; y_final *= 0.25; status_bar_height *= 0.25; break; case 1: // medium mWidth *= 0.5; mHeight *= 0.5; x_inicial *= 0.5; x_final *= 0.5; y_inicial *= 0.5; y_final *= 0.5; status_bar_height *= 0.5; break; case 2: //high mWidth *= 0.75; mHeight *= 0.75; x_inicial *= 0.75; x_final *= 0.75; y_inicial *= 0.75; y_final *= 0.75; status_bar_height *= 0.75; break; } storage = Environment.getExternalStorageDirectory().getAbsolutePath(); }
From source file:com.hemou.component.saripaar.Validator.java
private View getView(Field field) { try {/* ww w .j av a2s . c om*/ field.setAccessible(true); Object instance = mController; return (View) field.get(instance); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } return null; }
From source file:it.wami.map.mongodeploy.OsmSaxHandler.java
private void saveTag(String key, String value) { if (Arrays.asList(Tag.TYPES).contains(key)) { Tag tag = new Tag(); tag.setKeyValue(key, value);// ww w.j a v a 2 s .co m Map<String, String> pair = new HashMap<String, String>(); pair.put(key, value); if (pairList.contains(pair)) return; pairList.add(pair); DBCollection coll = db.getCollection(COLL_TAGS); //if(coll.find(new BasicDBObject(key, value)).count() > 0) //return; try { // this speed up the proccess coll.insert(tag, WriteConcern.UNACKNOWLEDGED); } catch (IllegalArgumentException e) { e.printStackTrace(); } } }
From source file:com.github.fauu.natrank.service.MatchDataImportServiceImpl.java
@Override public ProcessedMatchData processMatchData(String rawMatchData) { ProcessedMatchData matchData = new ProcessedMatchData(); DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("dd/MM/yyyy"); int lineNo = 1; BufferedReader reader = new BufferedReader(new StringReader(rawMatchData)); try {//from www .ja va 2 s . c o m String line; while ((line = reader.readLine()) != null) { String[] splitLine = line.split(";"); int numFields = splitLine.length; if (numFields == 6) { for (int i = 0; i < numFields; i++) { if (splitLine[i] == null || splitLine[i].trim().length() == 0) { MatchDataError error = new MatchDataError(lineNo, line, MatchDataError.Type.ERROR_MISSING_FIELD); matchData.getErrors().add(error); } } ParsedRawMatchDatum match = new ParsedRawMatchDatum(); LocalDate matchDate; try { matchDate = dateTimeFormatter.parseLocalDate(splitLine[0]); } catch (IllegalArgumentException e) { MatchDataError error = new MatchDataError(lineNo, line, MatchDataError.Type.ERROR_INCORRECT_DATE_FORMAT); matchData.getErrors().add(error); e.printStackTrace(); matchDate = null; } String matchType = splitLine[1]; String matchCity = splitLine[2]; String matchTeam1 = splitLine[3]; String matchTeam2 = splitLine[4]; String matchResult = splitLine[5]; Country team1Country = countryRepository.findByName(matchTeam1); Country team2Country = countryRepository.findByName(matchTeam2); if ((team1Country != null) && (team2Country != null)) { List<Match> duplicates = matchRepository.findByDateAndTeam1AndTeam2(matchDate, team1Country.getTeam(), team2Country.getTeam()); if (duplicates.size() > 0) { continue; } } match.setDate(matchDate); match.setType(matchType); match.setCity(matchCity); match.setTeam1(matchTeam1); match.setTeam2(matchTeam2); match.setResult(matchResult); matchData.getMatches().add(match); } else { MatchDataError error = new MatchDataError(lineNo, line, MatchDataError.Type.ERROR_INCORRECT_LINE_FORMAT); matchData.getErrors().add(error); } lineNo++; } } catch (IOException e) { e.printStackTrace(); } finally { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } if (matchData.getErrors().size() == 0) { List<String> existingCountryNames = countryRepository.findAllNames(); Set<String> processedNewCountryNames = new HashSet<>(); List<String> existingCityNames = cityRepository.findAllNames(); Set<String> processedNewCityNames = new HashSet<>(); List<String> existingMatchTypesFifaNames = matchTypeRepository.findAllFifaNames(); Set<String> processedNewMatchTypeFifaNames = new HashSet<>(); List<String> countryNamesTemp = new LinkedList<>(); for (ParsedRawMatchDatum parsedRawMatchDatum : matchData.getMatches()) { String matchTypeFifaName = parsedRawMatchDatum.getType(); if (!processedNewMatchTypeFifaNames.contains(matchTypeFifaName) && !existingMatchTypesFifaNames.contains(matchTypeFifaName)) { MatchType newType = new MatchType(); newType.setFifaName(matchTypeFifaName); processedNewMatchTypeFifaNames.add(matchTypeFifaName); matchData.getTypes().add(newType); } countryNamesTemp.add(parsedRawMatchDatum.getTeam1()); countryNamesTemp.add(parsedRawMatchDatum.getTeam2()); for (String countryName : countryNamesTemp) { if (!processedNewCountryNames.contains(countryName) && !existingCountryNames.contains(countryName)) { Country newCountry = new Country(); newCountry.setName(countryName); newCountry.setPeriod(new Period()); newCountry.getPeriod().setFromDate(parsedRawMatchDatum.getDate()); List<CountryCode> matchingCountryCodes = countryCodeRepository .findByCountryName(newCountry.getName()); String inferredCountryCode = ""; if (matchingCountryCodes.size() > 0) { inferredCountryCode = matchingCountryCodes.get(0).getCode(); } newCountry.setCode(inferredCountryCode); processedNewCountryNames.add(newCountry.getName()); matchData.getCountries().add(newCountry); } } countryNamesTemp.clear(); String cityName = parsedRawMatchDatum.getCity(); if (!processedNewCityNames.contains(cityName) && !existingCityNames.contains(cityName)) { City newCity = new City(); newCity.setName(cityName); CityCountryAssoc cityCountryAssoc = new CityCountryAssoc(); cityCountryAssoc.setCity(newCity); cityCountryAssoc.setPeriod(new Period()); cityCountryAssoc.getPeriod().setFromDate(parsedRawMatchDatum.getDate()); newCity.getCityCountryAssocs().add(cityCountryAssoc); processedNewCityNames.add(cityName); matchData.getCities().add(newCity); matchData.getCitiesInferredCountryNames().add(parsedRawMatchDatum.getTeam1()); } } } return matchData; }
From source file:com.lcw.one.common.persistence.BaseDao.java
/** * ?// w w w . java 2 s.c o m * @param entity */ public void save(T entity) { try { // ?? Object id = null; for (Method method : entity.getClass().getMethods()) { Id idAnn = method.getAnnotation(Id.class); if (idAnn != null) { id = method.invoke(entity); break; } } // ?? if (StringUtils.isBlank((String) id)) { for (Method method : entity.getClass().getMethods()) { PrePersist pp = method.getAnnotation(PrePersist.class); if (pp != null) { method.invoke(entity); break; } } } // ? else { for (Method method : entity.getClass().getMethods()) { PreUpdate pu = method.getAnnotation(PreUpdate.class); if (pu != null) { method.invoke(entity); break; } } } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } getSession().saveOrUpdate(entity); }
From source file:de.bund.bfr.fskml.MetadataDocument.java
private void addIndependentVariable(final Model model, final Variable v) { if (StringUtils.isEmpty(v.name)) return;/*from w w w .j ava2 s.com*/ Parameter param = model.createParameter(PMFUtil.createId(v.name)); param.setName(v.name); // Write value if v.type and v.value are not null if (v.type != null && StringUtils.isNotEmpty(v.value)) { if (v.type == DataType.integer) { param.setValue(Double.valueOf(v.value).intValue()); } else if (v.type == DataType.numeric) { param.setValue(Double.valueOf(v.value)); } else if (v.type == DataType.array) { param.setValue(0); // Remove "c(" and ")" around the values in the array String cleanArray = v.value.substring(2, v.value.length() - 1); // Split values into tokens using the comma as splitter String[] tokens = cleanArray.split(","); double[] values = Arrays.stream(tokens).mapToDouble(Double::parseDouble).toArray(); new ParameterArray(param, v.name, values); } } else if (v.type == DataType.character) { // TODO: Add character return; } // Write unit if v.unit is not null if (StringUtils.isNotEmpty(v.unit)) { try { param.setUnits(PMFUtil.createId(v.unit)); } catch (IllegalArgumentException e) { e.printStackTrace(); } } // Write min and max values if not null if (StringUtils.isNoneEmpty(v.min, v.max)) { try { double min = Double.parseDouble(v.min); double max = Double.parseDouble(v.max); LimitsConstraint lc = new LimitsConstraint(param.getId(), min, max); if (lc.getConstraint() != null) { model.addConstraint(lc.getConstraint()); } } catch (NumberFormatException e) { e.printStackTrace(); } } }
From source file:com.bitants.wally.fragments.SearchFragment.java
private void showColorPickerDialog() { FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager != null) { int color = Color.BLACK; try {//w w w.j av a 2s .co m color = Color.parseColor(currentColor != null ? "#" + currentColor : "#000000"); } catch (IllegalArgumentException e) { e.printStackTrace(); } ColorPickerDialogFragment colorPickerDialogFragment = new ColorPickerDialogFragment(color, null, getColorPickerOnDialogButtonClickedListener()); colorPickerDialogFragment.show(fragmentManager, ColorPickerDialogFragment.TAG); } }
From source file:io.github.huherto.springyRecords.RecordMapper.java
/** * Extract the values for all columns in the current row. * <p>Utilizes public setters and result set metadata. * @see java.sql.ResultSetMetaData// w w w .java2 s . c o m */ @Override public T mapRow(ResultSet rs, int rowNumber) throws SQLException { Assert.state(this.mappedClass != null, "Mapped class was not specified"); T mappedObject; try { mappedObject = mappedClass.newInstance(); } catch (Exception ex) { throw new RuntimeException(ex); } ResultSetMetaData rsmd = rs.getMetaData(); int columnCount = rsmd.getColumnCount(); for (int index = 1; index <= columnCount; index++) { String column = JdbcUtils.lookupColumnName(rsmd, index); Field field = this.mappedFields.get(column.replaceAll(" ", "")); if (field != null) { Object value = getColumnValue(rs, index, field); if (logger.isTraceEnabled() && rowNumber == 0) { logger.trace("Mapping column '" + column + "' to property '" + field.getName() + "' of type " + field.getType()); } try { field.set(mappedObject, value); } catch (IllegalArgumentException e) { if (value == null && primitivesDefaultedForNullValue) { logger.debug("Intercepted IllegalArgumentException for row " + rowNumber + " and column '" + column + "' with value " + value + " when setting property '" + field.getName() + "' of type " + field.getType() + " on object: " + mappedObject); } else { throw e; } } catch (IllegalAccessException e) { e.printStackTrace(); } } } return mappedObject; }
From source file:com.klinker.android.twitter.utils.NotificationUtils.java
public static void refreshNotification(Context context, boolean noTimeline) { AppSettings settings = AppSettings.getInstance(context); SharedPreferences sharedPrefs = context.getSharedPreferences( "com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); int currentAccount = sharedPrefs.getInt("current_account", 1); //int[] unreadCounts = new int[] {4, 1, 2}; // for testing int[] unreadCounts = getUnreads(context); int timeline = unreadCounts[0]; int realTimelineCount = timeline; // if they don't want that type of notification, simply set it to zero if (!settings.timelineNot || (settings.pushNotifications && settings.liveStreaming) || noTimeline) { unreadCounts[0] = 0;/*from w ww .java 2s . c om*/ } if (!settings.mentionsNot) { unreadCounts[1] = 0; } if (!settings.dmsNot) { unreadCounts[2] = 0; } if (unreadCounts[0] == 0 && unreadCounts[1] == 0 && unreadCounts[2] == 0) { } else { Intent markRead = new Intent(context, MarkReadService.class); PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0); String shortText = getShortText(unreadCounts, context, currentAccount); String longText = getLongText(unreadCounts, context, currentAccount); // [0] is the full title and [1] is the screenname String[] title = getTitle(unreadCounts, context, currentAccount); boolean useExpanded = useExp(context); boolean addButton = addBtn(unreadCounts); if (title == null) { return; } Intent resultIntent; if (unreadCounts[1] != 0 && unreadCounts[0] == 0) { // it is a mention notification (could also have a direct message) resultIntent = new Intent(context, RedirectToMentions.class); } else if (unreadCounts[2] != 0 && unreadCounts[0] == 0 && unreadCounts[1] == 0) { // it is a direct message resultIntent = new Intent(context, RedirectToDMs.class); } else { resultIntent = new Intent(context, MainActivity.class); } PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0); NotificationCompat.Builder mBuilder; Intent deleteIntent = new Intent(context, NotificationDeleteReceiverOne.class); mBuilder = new NotificationCompat.Builder(context).setContentTitle(title[0]) .setContentText(TweetLinkUtils.removeColorHtml(shortText, settings)) .setSmallIcon(R.drawable.ic_stat_icon).setLargeIcon(getIcon(context, unreadCounts, title[1])) .setContentIntent(resultPendingIntent).setAutoCancel(true) .setTicker(TweetLinkUtils.removeColorHtml(shortText, settings)) .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0)) .setPriority(NotificationCompat.PRIORITY_HIGH); if (unreadCounts[1] > 1 && unreadCounts[0] == 0 && unreadCounts[2] == 0) { // inbox style notification for mentions mBuilder.setStyle(getMentionsInboxStyle(unreadCounts[1], currentAccount, context, TweetLinkUtils.removeColorHtml(shortText, settings))); } else if (unreadCounts[2] > 1 && unreadCounts[0] == 0 && unreadCounts[1] == 0) { // inbox style notification for direct messages mBuilder.setStyle(getDMInboxStyle(unreadCounts[1], currentAccount, context, TweetLinkUtils.removeColorHtml(shortText, settings))); } else { // big text style for an unread count on timeline, mentions, and direct messages mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml( settings.addonTheme ? longText.replaceAll("FF8800", settings.accentColor) : longText))); } // Pebble notification if (sharedPrefs.getBoolean("pebble_notification", false)) { sendAlertToPebble(context, title[0], shortText); } // Light Flow notification sendToLightFlow(context, title[0], shortText); int homeTweets = unreadCounts[0]; int mentionsTweets = unreadCounts[1]; int dmTweets = unreadCounts[2]; int newC = 0; if (homeTweets > 0) { newC++; } if (mentionsTweets > 0) { newC++; } if (dmTweets > 0) { newC++; } if (settings.notifications && newC > 0) { if (settings.vibrate) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } if (settings.sound) { try { mBuilder.setSound(Uri.parse(settings.ringtone)); } catch (Exception e) { mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); } } if (settings.led) mBuilder.setLights(0xFFFFFF, 1000, 1000); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); if (addButton) { // the reply and read button should be shown Intent reply; if (unreadCounts[1] == 1) { reply = new Intent(context, NotificationCompose.class); } else { reply = new Intent(context, NotificationDMCompose.class); } Log.v("username_for_noti", title[1]); sharedPrefs.edit().putString("from_notification", "@" + title[1] + " " + title[2]).commit(); MentionsDataSource data = MentionsDataSource.getInstance(context); long id = data.getLastIds(currentAccount)[0]; PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0); sharedPrefs.edit().putLong("from_notification_long", id).commit(); sharedPrefs.edit() .putString("from_notification_text", "@" + title[1] + ": " + TweetLinkUtils.removeColorHtml(shortText, settings)) .commit(); // Create the remote input RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY) .setLabel("@" + title[1] + " ").build(); // Create the notification action NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder( R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply), replyPending).addRemoteInput(remoteInput).build(); NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder( R.drawable.ic_action_read_dark, context.getResources().getString(R.string.mark_read), readPending); mBuilder.addAction(replyAction); mBuilder.addAction(action.build()); } else { // otherwise, if they can use the expanded notifications, the popup button will be shown Intent popup = new Intent(context, RedirectToPopup.class); popup.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); popup.putExtra("from_notification", true); PendingIntent popupPending = PendingIntent.getActivity(context, 0, popup, 0); NotificationCompat.Action.Builder action = new NotificationCompat.Action.Builder( R.drawable.ic_popup, context.getResources().getString(R.string.popup), popupPending); mBuilder.addAction(action.build()); } // Build the notification and issues it with notification manager. notificationManager.notify(1, mBuilder.build()); // if we want to wake the screen on a new message if (settings.wakeScreen) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); wakeLock.acquire(5000); } } // if there are unread tweets on the timeline, check them for favorite users if (settings.favoriteUserNotifications && realTimelineCount > 0) { favUsersNotification(currentAccount, context); } } try { ContentValues cv = new ContentValues(); cv.put("tag", "com.klinker.android.twitter/com.klinker.android.twitter.ui.MainActivity"); // add the direct messages and mentions cv.put("count", unreadCounts[1] + unreadCounts[2]); context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); } catch (IllegalArgumentException ex) { /* Fine, TeslaUnread is not installed. */ } catch (Exception ex) { /* Some other error, possibly because the format of the ContentValues are incorrect. Log but do not crash over this. */ ex.printStackTrace(); } }
From source file:hd3gtv.mydmam.db.orm.CassandraOrm.java
private ArrayList<Field> getOrmobjectUsableFields() { ArrayList<Field> result = new ArrayList<Field>(); Field[] fields = this.reference.getFields(); Field field;/*from w w w . j av a2 s. co m*/ int mod; for (int pos_df = 0; pos_df < fields.length; pos_df++) { field = fields[pos_df]; if (field.isAnnotationPresent(Transient.class)) { /** * Is transient ? */ continue; } if (field.getName().equals("key")) { /** * Not this (primary key) */ continue; } mod = field.getModifiers(); if ((mod & Modifier.PROTECTED) != 0) continue; if ((mod & Modifier.PRIVATE) != 0) continue; if ((mod & Modifier.ABSTRACT) != 0) continue; if ((mod & Modifier.STATIC) != 0) continue; if ((mod & Modifier.FINAL) != 0) continue; if ((mod & Modifier.TRANSIENT) != 0) continue; if ((mod & Modifier.INTERFACE) != 0) continue; try { result.add(field); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } } return result; }