List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:pedroscott.com.popularmoviesapp.app.ui.home.HomeFragment.java
private void loadMovies(String sort) { isFavoriteScream = false;/*from w w w. java2s . c om*/ selectSort = sort; App.getRestClientPublic().getPublicService().getMovies(page, sort).enqueue(new Callback<ResponseMovies>() { @Override public void onResponse(Response<ResponseMovies> response, Retrofit retrofit) { try { movies.addAll(response.body().getResults()); adapter.setData(movies); validateEntryState(getString(R.string.no_movies)); DebugUtils.PrintLogMessage(TAG, response.toString(), DebugUtils.DebugMessageType.ERROR); } catch (NullPointerException e) { e.printStackTrace(); } } @Override public void onFailure(Throwable t) { DebugUtils.PrintLogMessage(TAG, t.toString(), DebugUtils.DebugMessageType.ERROR); validateEntryState(getString(R.string.error_server)); } }); }
From source file:com.near.chimerarevo.fragments.SettingsFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {//from w w w.j a v a2s . c o m ((BaseActivity) getActivity()).getToolbar() .setTitle(getResources().getString(R.string.action_settings)); } catch (NullPointerException e) { e.printStackTrace(); } addPreferencesFromResource(R.xml.prefs); findPreference("gallery_num_pref") .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { int num = Integer.parseInt(newValue.toString()); if (num < 0 || num > 999) { SnackbarUtils .showShortSnackbar(getActivity(), getResources().getString(R.string.error_value_notvalid)) .show(getActivity()); return false; } else return true; } }); findPreference("comments_reset_pref") .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { getActivity().getSharedPreferences(Constants.PREFS_TAG, Context.MODE_PRIVATE).edit() .remove(Constants.KEY_REFRESH_TOKEN).commit(); SnackbarUtils .showLongSnackbar(getActivity(), getResources().getString(R.string.comments_reset_toast)) .show(getActivity()); return true; } }); findPreference("show_tutorial_pref") .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { startActivity(new Intent(getActivity(), TutorialActivity.class)); return true; } }); ((SeekBarPreference) findPreference("text_size_pref")).setParameters(" sp", 1, PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt("text_size_pref", 16), 10); findPreference("notification_delay_pref") .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { setAlarm(Integer.parseInt((String) newValue), true); return true; } }); findPreference("news_search_pref") .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { boolean isChecked = (Boolean) newValue; setAlarm(Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString("notification_delay_pref", "0")), isChecked); return true; } }); }
From source file:de.vandermeer.skb.datatool.commons.DataSet.java
/** * Loads a data set from file system, does many consistency checks as well. * @param fsl list of files to load data from * @param fileExt the file extension used (translated to "." + fileExt + ".json"), empty if none used * @return 0 on success, larger than zero on JSON parsing error (number of found errors) *//* w w w. j a va 2s . co m*/ @SuppressWarnings("unchecked") public int load(List<FileSource> fsl, String fileExt) { int ret = 0; String commonPath = this.calcCommonPath(fsl); for (FileSource fs : fsl) { String keyStart = this.calcKeyStart(fs, commonPath); ObjectMapper om = new ObjectMapper(); om.configure(JsonParser.Feature.ALLOW_COMMENTS, true); try { List<Map<String, Object>> jsonList = om.readValue(fs.asFile(), new TypeReference<ArrayList<HashMap<String, Object>>>() { }); for (Map<String, Object> entryMap : jsonList) { E entry = this.factory.newInstanceLoaded(keyStart, entryMap); if (entry.getKey().contains("#dummy")) { continue; } String dup = entry.testDuplicate((Collection<DataEntry>) this.entries.values()); if (this.entries.containsKey(entry.getKey())) { Skb_Console.conError("{}: duplicate key <{}> found in file <{}>", new Object[] { this.cs.getAppName(), entry.getKey(), fs.getAbsoluteName() }); } else if (dup != null) { Skb_Console.conError("{}: entry already in map: k1 <{}> <> k2 <{}> found in file <{}>", new Object[] { this.cs.getAppName(), dup, entry.getKey(), fs.getAbsoluteName() }); } else { if (this.excluded == null || (!ArrayUtils.contains(this.excluded, entry.getCompareString()))) { this.entries.put(entry.getKey(), (E) entry); } } } this.files++; } catch (IllegalArgumentException iaex) { Skb_Console.conError("{}: problem creating entry: <{}> in file <{}>", new Object[] { this.cs.getAppName(), iaex.getMessage(), fs.getAbsoluteName() }); ret++; } catch (URISyntaxException ue) { Skb_Console.conError("{}: problem creating a URI for a link: <{}> in file <{}>", new Object[] { this.cs.getAppName(), ue.getMessage(), fs.getAbsoluteName() }); ret++; } catch (NullPointerException npe) { npe.printStackTrace(); ret++; } catch (Exception ex) { Skb_Console.conError( "reading acronym from JSON failed with exception <{}>, cause <{}> and message <{}> in file <{}>", new Object[] { ex.getClass().getSimpleName(), ex.getCause(), ex.getMessage(), fs.getAbsoluteName() }); ret++; } } return ret; }
From source file:tm.alashow.dotjpg.ui.activity.ViewImageActivity.java
@Override protected void onCreate(Bundle inState) { super.onCreate(inState); setContentView(R.layout.activity_view_image); //Hiding System UI getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); try {//from w w w . j ava 2s . c om ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.hide(); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_transculate)); actionBar.setDisplayHomeAsUpEnabled(true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); } } catch (NullPointerException e) { e.printStackTrace(); } ArrayList<String> imageList = getIntent().getStringArrayListExtra(Config.EXTRA_URLS); int position = getIntent().getIntExtra(Config.EXTRA_POSITION, 0); HackyViewPager pager = (HackyViewPager) findViewById(R.id.viewPager); pager.setAdapter(new ImagesFragmentAdapter(getSupportFragmentManager(), imageList)); pager.setCurrentItem(position); pager.setPageTransformer(true, new ZoomOutPageTransformer()); }
From source file:com.endgame.binarypig.loaders.AbstractFileDroppingLoader.java
public void cleanUp() { try {//ww w .j a va2s.c o m FileUtils.deleteDirectory(dataDir); } catch (NullPointerException e) { } catch (Exception e) { e.printStackTrace(); } }
From source file:com.nikolak.weatherapp.SettingsActivity.java
/** * Set up the {@link android.app.ActionBar}, if the API is available. *//*from w w w . jav a 2 s. c om*/ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setupActionBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // Show the Up button in the action bar. try { getActionBar().setDisplayHomeAsUpEnabled(true); } catch (NullPointerException e) { e.printStackTrace(); } } }
From source file:com.endgame.binarypig.loaders.AbstractFileDroppingLoader.java
@Override public void prepareToRead(RecordReader reader, PigSplit split) throws IOException { // cast any reader object into a SequenceFileRecordReader. We do not care about the split. We keep with sequencefile, as our base // filetype is a sequence file. All the fanciness is post-sequence. try {// w ww. j av a 2 s .c om FileSplit filesplit = (FileSplit) split.getWrappedSplit(); System.out.println("filesplit: " + filesplit.getPath()); } catch (NullPointerException e) { } catch (Exception e) { e.printStackTrace(); } this.reader = (SequenceFileRecordReader) reader; workingDir = new File(".").getAbsoluteFile(); makeDataDir(); init(); }
From source file:com.wmendez.newsreader.lib.ui.views.NewsItemView.java
private void fetchImage() { Picasso.with(mContext).load(mEntry.image).placeholder(R.drawable.ic_launcher).into(image, new Callback() { @Override/* www . j a v a2s . c o m*/ public void onSuccess() { Palette palette = Palette.generate(((BitmapDrawable) image.getDrawable()).getBitmap()); Palette.Swatch mutedSwatch = palette.getMutedSwatch(); try { setBackgroundColor(mutedSwatch.getRgb()); int titleTextColor = mutedSwatch.getTitleTextColor(); title.setTextColor(titleTextColor); pubDate.setTextColor(titleTextColor); summary.setTextColor(titleTextColor); } catch (NullPointerException ex) { ex.printStackTrace(); } } @Override public void onError() { image.setVisibility(GONE); summary.setVisibility(VISIBLE); reDraw(); } }); }
From source file:fr.redteam.dressyourself.plugins.weather.yahooWeather.YahooWeatherUtils.java
private WeatherInfo parseWeatherInfo(Context context, Document doc) { WeatherInfo weatherInfo = new WeatherInfo(); try {/* www. j a v a 2 s. c om*/ Node titleNode = doc.getElementsByTagName("title").item(0); if (titleNode.getTextContent().equals(YAHOO_WEATHER_ERROR)) { return null; } weatherInfo.setTitle(titleNode.getTextContent()); weatherInfo.setDescription(doc.getElementsByTagName("description").item(0).getTextContent()); weatherInfo.setLanguage(doc.getElementsByTagName("language").item(0).getTextContent()); weatherInfo.setLastBuildDate(doc.getElementsByTagName("lastBuildDate").item(0).getTextContent()); Node locationNode = doc.getElementsByTagName("yweather:location").item(0); weatherInfo.setLocationCity(locationNode.getAttributes().getNamedItem("city").getNodeValue()); weatherInfo.setLocationRegion(locationNode.getAttributes().getNamedItem("region").getNodeValue()); weatherInfo.setLocationCountry(locationNode.getAttributes().getNamedItem("country").getNodeValue()); Node windNode = doc.getElementsByTagName("yweather:wind").item(0); weatherInfo.setWindChill(windNode.getAttributes().getNamedItem("chill").getNodeValue()); weatherInfo.setWindDirection(windNode.getAttributes().getNamedItem("direction").getNodeValue()); weatherInfo.setWindSpeed(windNode.getAttributes().getNamedItem("speed").getNodeValue()); Node atmosphereNode = doc.getElementsByTagName("yweather:atmosphere").item(0); weatherInfo .setAtmosphereHumidity(atmosphereNode.getAttributes().getNamedItem("humidity").getNodeValue()); weatherInfo.setAtmosphereVisibility( atmosphereNode.getAttributes().getNamedItem("visibility").getNodeValue()); weatherInfo .setAtmospherePressure(atmosphereNode.getAttributes().getNamedItem("pressure").getNodeValue()); weatherInfo.setAtmosphereRising(atmosphereNode.getAttributes().getNamedItem("rising").getNodeValue()); Node astronomyNode = doc.getElementsByTagName("yweather:astronomy").item(0); weatherInfo.setAstronomySunrise(astronomyNode.getAttributes().getNamedItem("sunrise").getNodeValue()); weatherInfo.setAstronomySunset(astronomyNode.getAttributes().getNamedItem("sunset").getNodeValue()); weatherInfo.setConditionTitle(doc.getElementsByTagName("title").item(2).getTextContent()); weatherInfo.setConditionLat(doc.getElementsByTagName("geo:lat").item(0).getTextContent()); weatherInfo.setConditionLon(doc.getElementsByTagName("geo:long").item(0).getTextContent()); Node currentConditionNode = doc.getElementsByTagName("yweather:condition").item(0); weatherInfo.setCurrentCode( Integer.parseInt(currentConditionNode.getAttributes().getNamedItem("code").getNodeValue())); weatherInfo.setCurrentText(currentConditionNode.getAttributes().getNamedItem("text").getNodeValue()); weatherInfo.setCurrentTempF( Integer.parseInt(currentConditionNode.getAttributes().getNamedItem("temp").getNodeValue())); weatherInfo.setCurrentConditionDate( currentConditionNode.getAttributes().getNamedItem("date").getNodeValue()); this.parseForecastInfo(weatherInfo.getForecastInfo1(), doc, 0); this.parseForecastInfo(weatherInfo.getForecastInfo2(), doc, 1); } catch (NullPointerException e) { e.printStackTrace(); Toast.makeText(context, "Parse XML failed - Unrecognized Tag", Toast.LENGTH_SHORT).show(); weatherInfo = null; } return weatherInfo; }
From source file:com.demonwav.mcdev.creator.ForgeProjectSettingsWizard.java
@Override public void onStepLeaving() { settings.pluginName = pluginNameField.getText(); settings.pluginVersion = pluginVersionField.getText(); settings.mainClass = mainClassField.getText(); settings.setAuthors(authorsField.getText()); settings.setDependencies(dependField.getText()); settings.description = descriptionField.getText(); settings.website = websiteField.getText(); settings.updateUrl = updateUrlField.getText(); settings.mcpVersion = ((McpVersionEntry) mcpVersionBox.getSelectedItem()).getText(); if (settings instanceof SpongeForgeProjectConfiguration) { SpongeForgeProjectConfiguration configuration = (SpongeForgeProjectConfiguration) settings; configuration.generateDocumentation = generateDocsCheckbox.isSelected(); configuration.spongeApiVersion = (String) minecraftVersionBox.getSelectedItem(); }//from w w w . j av a 2 s. com // If an error occurs while fetching the API, this may prevent the user from closing the dialog. try { settings.forgeVersion = forgeVersion.getFullVersion((String) forgeVersionBox.getSelectedItem()); } catch (NullPointerException e) { e.printStackTrace(); } }