List of usage examples for java.util TimeZone getAvailableIDs
public static synchronized String[] getAvailableIDs(int rawOffset)
From source file:Main.java
public static void main(String args[]) { // getting available Ids for offset String[] availId = TimeZone.getAvailableIDs(3600000); // checking available Ids for offset System.out.println("Available Ids for offset are: "); for (int i = 0; i < availId.length; i++) { System.out.println(availId[i]); }//from w ww.j a v a2 s . c o m }
From source file:org.eclipse.hawkbit.ui.utils.SPDateTimeUtil.java
/** * Get browser time zone.//from w w w . j a v a 2s . co m * * @return TimeZone */ public static TimeZone getBrowserTimeZone() { final WebBrowser webBrowser = com.vaadin.server.Page.getCurrent().getWebBrowser(); final String[] timeZones = TimeZone.getAvailableIDs(webBrowser.getRawTimezoneOffset()); TimeZone tz = TimeZone.getDefault(); for (final String string : timeZones) { final TimeZone t = TimeZone.getTimeZone(string); if (t.getRawOffset() == webBrowser.getRawTimezoneOffset()) { tz = t; } } return tz; }
From source file:srvmonitor.thGetAgendas.java
@Override public void run() { /*/*from w w w.j a v a 2s .c o m*/ Recupera Parametros Fecha Actual */ logger.info("Buscando Agendas Activas"); String[] ids = TimeZone.getAvailableIDs(-4 * 60 * 60 * 1000); String clt = ids[0]; SimpleTimeZone tz = new SimpleTimeZone(-4 * 60 * 60 * 1000, clt); tz.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); tz.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(tz); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); // Jan = 0, dec = 11 int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); int weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR); int weekOfMonth = calendar.get(Calendar.WEEK_OF_MONTH); int hour = calendar.get(Calendar.HOUR); // 12 hour clock int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); // 24 hour clock int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); int millisecond = calendar.get(Calendar.MILLISECOND); int findHour = 12; int findMinutes = 5; /* calendar.add(Calendar.HOUR_OF_DAY, -1); int hourBefore = calendar.get(Calendar.HOUR_OF_DAY); calendar.add(Calendar.HOUR_OF_DAY, 2); int hourAfter = calendar.get(Calendar.HOUR_OF_DAY); */ String posmonth = String.valueOf(month + 1); String posdayOfMonth = String.valueOf(dayOfMonth); String posdayOfWeek = String.valueOf(dayOfWeek); String posweekOfYear = String.valueOf(weekOfYear); String posweekOfMonth = String.valueOf(weekOfMonth); String poshourOfDay = String.valueOf(hourOfDay); String posminute = String.valueOf(minute); String possecond = String.valueOf(second); String posmillisecond = String.valueOf(millisecond); Calendar iteratorCalendar; String vSQL; String iteratorHour; String iteratorMinute; Statement stm; JSONObject jData; JSONObject jDataMinute; JSONArray jArray = new JSONArray(); JSONArray jArrayMinute = new JSONArray(); String posIteratorHour; String posIteratorMinute; /* Inicializa Lista de Agendas */ gDatos.getLstShowAgendas().clear(); gDatos.getLstActiveAgendas().clear(); for (int i = -findHour; i <= findHour; i++) { iteratorCalendar = new GregorianCalendar(tz); iteratorCalendar.add(Calendar.HOUR_OF_DAY, i); iteratorHour = String.valueOf(iteratorCalendar.get(Calendar.HOUR_OF_DAY)); posIteratorHour = String.valueOf(Integer.valueOf(iteratorHour) + 1); vSQL = "select " + iteratorHour + " horaAgenda,ageID, month, dayOfMonth, dayOfWeek, weekOfYear, weekOfMonth, hourOfDay from process.tb_agenda where " + " ageEnable=1 " + " and substr(month," + posmonth + ",1) = '1'" + " and substr(dayOfMonth," + posdayOfMonth + ",1) = '1'" + " and substr(dayOfWeek," + posdayOfWeek + ",1) = '1'" + " and substr(weekOfYear," + posweekOfYear + ",1) = '1'" + " and substr(weekOfMonth," + posweekOfMonth + ",1) = '1'" + " and substr(hourOfDay," + posIteratorHour + ",1) = '1'"; logger.debug("i: " + i + " vSQL: " + vSQL); try { stm = gDatos.getServerStatus().getMetadataConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); jData = new JSONObject(); ResultSet rs = stm.executeQuery(vSQL); if (rs != null) { while (rs.next()) { jData = new JSONObject(); jData.put("horaAgenda", rs.getString("horaAgenda")); jData.put("ageID", rs.getString("ageID")); jData.put("month", rs.getString("month")); jData.put("dayOfMonth", rs.getString("dayOfMonth")); jData.put("weekOfYear", rs.getString("weekOfYear")); jData.put("weekOfMonth", rs.getString("weekOfMonth")); jData.put("hourOfDay", rs.getString("hourOfDay")); jArray.put(jData); gDatos.getLstShowAgendas().add(jData); } } else { jData.put("horaAgenda", iteratorHour); jData.put("ageID", ""); jData.put("month", ""); jData.put("dayOfMonth", ""); jData.put("weekOfYear", ""); jData.put("weekOfMonth", ""); jData.put("hourOfDay", ""); jArray.put(jData); gDatos.getLstShowAgendas().add(jData); System.out.println("No hay registros"); } stm.close(); } catch (SQLException | JSONException e) { logger.error(e.getMessage()); } } iteratorCalendar = new GregorianCalendar(tz); iteratorHour = String.valueOf(iteratorCalendar.get(Calendar.HOUR_OF_DAY)); posIteratorHour = String.valueOf(Integer.valueOf(iteratorHour) + 1); for (int i = -findMinutes; i <= 0; i++) { iteratorCalendar = new GregorianCalendar(tz); iteratorCalendar.add(Calendar.MINUTE, i); iteratorMinute = String.valueOf(iteratorCalendar.get(Calendar.MINUTE)); posIteratorMinute = String.valueOf(Integer.valueOf(iteratorMinute) + 1); vSQL = "select " + iteratorMinute + " horaAgenda,ageID, month, dayOfMonth, dayOfWeek, weekOfYear, weekOfMonth, hourOfDay from process.tb_agenda where " + " ageEnable=1 " + " and substr(month," + posmonth + ",1) = '1'" + " and substr(dayOfMonth," + posdayOfMonth + ",1) = '1'" + " and substr(dayOfWeek," + posdayOfWeek + ",1) = '1'" + " and substr(weekOfYear," + posweekOfYear + ",1) = '1'" + " and substr(weekOfMonth," + posweekOfMonth + ",1) = '1'" + " and substr(hourOfDay," + posIteratorHour + ",1) = '1'" + " and substr(minute," + posIteratorMinute + ",1) = '1'"; logger.debug("i: " + i + " vSQL: " + vSQL); try { stm = gDatos.getServerStatus().getMetadataConnection().createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stm.executeQuery(vSQL); if (rs != null) { while (rs.next()) { jDataMinute = new JSONObject(); jDataMinute.put("horaAgenda", rs.getString("horaAgenda")); jDataMinute.put("ageID", rs.getString("ageID")); jDataMinute.put("month", rs.getString("month")); jDataMinute.put("dayOfMonth", rs.getString("dayOfMonth")); jDataMinute.put("weekOfYear", rs.getString("weekOfYear")); jDataMinute.put("weekOfMonth", rs.getString("weekOfMonth")); jDataMinute.put("hourOfDay", rs.getString("hourOfDay")); jArrayMinute.put(jDataMinute); gDatos.getLstActiveAgendas().add(jDataMinute); } } stm.close(); } catch (SQLException | JSONException e) { logger.error(e.getMessage()); } } for (int i = 0; i < gDatos.getLstShowAgendas().size(); i++) { logger.debug(gDatos.getLstShowAgendas().get(i).toString()); } for (int i = 0; i < gDatos.getLstActiveAgendas().size(); i++) { logger.debug(gDatos.getLstActiveAgendas().get(i).toString()); } logger.info("Finaliza busquenda agendas activas..."); }
From source file:org.obm.push.protocol.data.TZDecoder.java
public TimeZone decode(String b64) { // Doc : [MS-ASDTYPE] 2.7 TimeZone // Doc about types : // http://msdn.microsoft.com/fr-fr/library/bb469811.aspx // 1 LONG = 4 bytes // 1 WCHAR = 2 bytes // 1 SYSTEMTIME = 8 SHORT = 8 X 2 bytes // TOTAL TIMEZONE STRUCT must be 172 bytes byte tzstruct[] = Base64.decodeBase64(b64); ByteBuffer bfBias = ByteBuffer.wrap(tzstruct, 0, 4); // NOT YET USED ////from ww w. j ava 2s. c o m // ByteBuffer bfStandardName = ByteBuffer.wrap(tzstruct, 4, 64); // ByteBuffer bfStandardDate = ByteBuffer.wrap(tzstruct, 68, 16); // ByteBuffer bfStandardBias = ByteBuffer.wrap(tzstruct, 84, 4); // ByteBuffer bfDaylightName = ByteBuffer.wrap(tzstruct, 88, 64); // ByteBuffer bfDaylightDate = ByteBuffer.wrap(tzstruct, 152, 16); // ByteBuffer bfDaylightBias = ByteBuffer.wrap(tzstruct, 168, 4); bfBias.order(ByteOrder.LITTLE_ENDIAN); int bias = bfBias.getInt(); // Java integer is 4-bytes-long // NOT YET USED // // bfStandardBias.order(ByteOrder.LITTLE_ENDIAN); // int standardBias = bfStandardBias.getInt(); // // bfDaylightBias.order(ByteOrder.LITTLE_ENDIAN); // int daylightBias = bfDaylightBias.getInt(); TimeZone timezone = TimeZone.getDefault(); timezone.setRawOffset(bias * 60 * 1000); String timezones[] = TimeZone.getAvailableIDs(bias * 60 * 1000); if (timezones.length > 0) { timezone = TimeZone.getTimeZone(timezones[0]); } // USEFUL DEBUG LINES // // StringBuffer sb = new StringBuffer(); // for (int i = 0; i < 172; i+=1) { // sb.append(Byte.valueOf(tzstruct[i]).intValue()); // } // // logger.info("b64: " + b64); // logger.info("tzstruct: "+ sb.toString()); // logger.info("bias: " + bias); // logger.info("standardbias: " + standardBias); // logger.info("standardname: " + // bfStandardName.asCharBuffer().toString()); // logger.info("daylightBias: " + daylightBias); return timezone; }
From source file:edu.ucsb.nceas.ezid.test.EZIDServiceTest.java
/** Generate a timestamp for use in IDs. */ public static String generateTimeString() { StringBuffer guid = new StringBuffer(); // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime);/* w ww . j a va 2s . c o m*/ guid.append(calendar.get(Calendar.YEAR)); guid.append(calendar.get(Calendar.DAY_OF_YEAR)); guid.append(calendar.get(Calendar.HOUR_OF_DAY)); guid.append(calendar.get(Calendar.MINUTE)); guid.append(calendar.get(Calendar.SECOND)); guid.append(calendar.get(Calendar.MILLISECOND)); double random = Math.random(); guid.append(random); return guid.toString(); }
From source file:org.jspresso.framework.application.startup.remote.RemoteStartup.java
/** * Starts the remote application passing it the client locale. * * @param startCommand// w w w.j ava 2 s . c om * the start command wrapping the various client start parameters. * @return the commands to be executed by the client peer on startup. */ public List<RemoteCommand> start(RemoteStartCommand startCommand) { try { Locale locale = LocaleUtils.toLocale(startCommand.getLanguage()); IFrontendController<RComponent, RIcon, RAction> controller = getFrontendController(); if (!dupSessionNotifiedOnce && isDupSessionDetectionEnabled() && controller != null && controller.isStarted()) { dupSessionNotifiedOnce = true; RemoteMessageCommand errorMessage = createErrorMessageCommand(); errorMessage.setMessage(controller.getTranslation("session.dup", new Object[] { controller.getI18nName(controller, locale) }, locale)); // Do not return the singleton list directly since subclasses might add commands to it. return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage)); } dupSessionNotifiedOnce = false; setStartupLocale(locale); TimeZone serverTimeZone = TimeZone.getDefault(); int currentOffset = serverTimeZone.getOffset(System.currentTimeMillis()); TimeZone clientTz = null; if (currentOffset == startCommand.getTimezoneOffset()) { clientTz = serverTimeZone; } else { String[] availableIds = TimeZone.getAvailableIDs(startCommand.getTimezoneOffset()); if (availableIds.length > 0) { for (int i = 0; i < availableIds.length && clientTz == null; i++) { TimeZone tz = TimeZone.getTimeZone(availableIds[i]); if (tz.useDaylightTime() == serverTimeZone.useDaylightTime()) { clientTz = tz; } } if (clientTz == null) { clientTz = TimeZone.getTimeZone(availableIds[0]); } } else { clientTz = TimeZone.getDefault(); } } setClientTimeZone(clientTz); start(); controller = getFrontendController(); if (startCommand.getVersion() != null && !isClientVersionCompatible(startCommand.getVersion())) { RemoteMessageCommand errorMessage = createErrorMessageCommand(); assert controller != null; errorMessage.setMessage(controller.getTranslation("incompatible.client.version", new Object[] { startCommand.getVersion(), Build.getJspressoVersion() }, locale)); // Do not return the singleton list directly since subclasses might add commands to it. return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage)); } try { return handleCommands(Collections.singletonList((RemoteCommand) startCommand)); } catch (Throwable ex) { if (controller != null) { controller.traceUnexpectedException(ex); } return Collections.emptyList(); } } catch (RuntimeException ex) { LOG.error("An unexpected error occurred while starting the server.", ex); RemoteMessageCommand errorMessage = createErrorMessageCommand(); errorMessage.setMessage( "An unexpected error occurred while starting the server. Please contact the application manager."); // Do not return the singleton list directly since subclasses might add commands to it. return new ArrayList<>(Collections.singleton((RemoteCommand) errorMessage)); } }
From source file:edu.harvard.iq.dvn.core.doi.DOIEZIdServiceBean.java
public static String generateYear() { StringBuffer guid = new StringBuffer(); // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime);/* w w w .j a va2 s. c om*/ guid.append(calendar.get(Calendar.YEAR)); return guid.toString(); }
From source file:edu.harvard.iq.dvn.core.doi.DOIEZIdServiceBean.java
public static String generateTimeString() { StringBuffer guid = new StringBuffer(); // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime);//from ww w . ja va 2s . c om guid.append(calendar.get(Calendar.YEAR)); guid.append(calendar.get(Calendar.DAY_OF_YEAR)); guid.append(calendar.get(Calendar.HOUR_OF_DAY)); guid.append(calendar.get(Calendar.MINUTE)); guid.append(calendar.get(Calendar.SECOND)); guid.append(calendar.get(Calendar.MILLISECOND)); double random = Math.random(); guid.append(random); return guid.toString(); }
From source file:edu.ucsb.nceas.metacattest.UploadIPCCDataTest.java
private String generateId() { int version = 1; StringBuffer docid = new StringBuffer(DATAIDPREFIX); docid.append(DOT);/*from w w w. jav a 2s. co m*/ // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); int time = 0; docid.append(calendar.get(Calendar.YEAR)); time = calendar.get(Calendar.DAY_OF_YEAR); if (time < 10) { docid.append("0"); docid.append("0"); docid.append(time); } else if (time < 100) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.HOUR_OF_DAY); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.MINUTE); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.SECOND); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } //sometimes this number is not unique, so we append a random number int random = (new Double(Math.random() * 100)).intValue(); docid.append(random); docid.append(DOT); docid.append(version); return docid.toString(); }
From source file:com.lastsoft.plog.adapter.GameAdapter.java
public void playPopup(View v, final int position) { try {/*from ww w . j av a2 s . co m*/ InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception ignored) { } PopupMenu popup = new PopupMenu(mActivity, v); MenuInflater inflater = popup.getMenuInflater(); if (games.get(position).expansionFlag == true) { inflater.inflate(R.menu.game_expansion_overflow, popup.getMenu()); } else { inflater.inflate(R.menu.game_overflow, popup.getMenu()); } if (games.get(position).gameBGGID == null || games.get(position).gameBGGID.equals("")) { popup.getMenu().removeItem(R.id.update_bgg); popup.getMenu().removeItem(R.id.open_bgg); popup.getMenu().removeItem(R.id.add_bgg); } if (games.get(position).gameBoxImage == null || games.get(position).gameBoxImage.equals("")) { popup.getMenu().removeItem(R.id.view_box_photo); } if (games.get(position).taggedToPlay <= 0) { popup.getMenu().removeItem(R.id.remove_bucket_list); } else { popup.getMenu().removeItem(R.id.add_bucket_list); } SharedPreferences app_preferences; app_preferences = PreferenceManager.getDefaultSharedPreferences(mActivity); long currentDefaultPlayer = app_preferences.getLong("defaultPlayer", -1); if (games.get(position).collectionFlag || currentDefaultPlayer == -1) { popup.getMenu().removeItem(R.id.add_bgg); } //check if this game has been played //if so, can't delete if (GamesPerPlay.hasGameBeenPlayed(games.get(position))) { popup.getMenu().removeItem(R.id.delete_game); } popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.delete_game: ((MainActivity) mActivity).deleteGame(games.get(position).getId()); return true; case R.id.add_tenbyten: ((MainActivity) mActivity).addToTenXTen(games.get(position).getId()); return true; case R.id.view_plays: if (games.get(position).expansionFlag == true) { ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 9, fragmentName, currentYear); } else { ((MainActivity) mActivity).openPlays(games.get(position).gameName, false, 0, fragmentName, currentYear); } return true; case R.id.open_bgg: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://bgg.cc/boardgame/" + games.get(position).gameBGGID)); mActivity.startActivity(browserIntent); return true; case R.id.update_bgg: mPosition = position; if (games.get(position).expansionFlag == true) { ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, true, -1); } else { ((MainActivity) mActivity).searchGameViaBGG(games.get(position).gameName, false, false, -1); } return true; case R.id.add_bgg: mPosition = position; ((MainActivity) mActivity).updateGameViaBGG(games.get(position).gameName, games.get(position).gameBGGID, "", true, false); return true; case R.id.add_box_photo: ((GamesFragment) mFragment).captureBox(games.get(position)); return true; case R.id.view_box_photo: String[] photoParts = games.get(position).gameBoxImage.split("/"); File newFile = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Plog/", photoParts[photoParts.length - 1]); Uri contentUri = FileProvider.getUriForFile(mActivity.getApplicationContext(), "com.lastsoft.plog.fileprovider", newFile); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(contentUri, "image/*"); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); mActivity.startActivity(intent); return true; case R.id.add_bucket_list: String[] ids = TimeZone.getAvailableIDs(-5 * 60 * 60 * 1000); // if no ids were returned, something is wrong. get out. //if (ids.length == 0) // System.exit(0); // begin output //System.out.println("Current Time"); // create a Eastern Standard Time time zone SimpleTimeZone pdt = new SimpleTimeZone(-5 * 60 * 60 * 1000, ids[0]); // set up rules for daylight savings time pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); // create a GregorianCalendar with the Pacific Daylight time zone // and the current date and time Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); int i = (int) (calendar.getTime().getTime() / 1000); games.get(position).taggedToPlay = i; games.get(position).save(); Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout, games.get(position).gameName + mActivity.getString(R.string.added_to_bl), Snackbar.LENGTH_LONG) .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() { @Override public void onClick(View view) { games.get(position).taggedToPlay = 0; games.get(position).save(); if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } } }).show(); // Do not forget to show! return true; case R.id.remove_bucket_list: final int taggedToPlay = games.get(position).taggedToPlay; final Game gameToUndo = games.get(position); games.get(position).taggedToPlay = 0; games.get(position).save(); Snackbar.make(((GamesFragment) mFragment).mCoordinatorLayout, games.get(position).gameName + mActivity.getString(R.string.removed_from_bl), Snackbar.LENGTH_LONG) .setAction(mActivity.getString(R.string.undo), new View.OnClickListener() { @Override public void onClick(View view) { gameToUndo.taggedToPlay = taggedToPlay; gameToUndo.save(); if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } } }).show(); // Do not forget to show! if (playListType == 2) { ((MainActivity) mActivity).onFragmentInteraction("refresh_games"); } return true; default: return false; } } } ); popup.show(); }