本文整理汇总了Java中com.google.gwt.storage.client.Storage.getLocalStorageIfSupported方法的典型用法代码示例。如果您正苦于以下问题:Java Storage.getLocalStorageIfSupported方法的具体用法?Java Storage.getLocalStorageIfSupported怎么用?Java Storage.getLocalStorageIfSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.storage.client.Storage
的用法示例。
在下文中一共展示了Storage.getLocalStorageIfSupported方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
view = clientFactory.getSeattleView();
dbService = clientFactory.getDbService();
analytics = clientFactory.getAnalytics();
view.setPresenter(this);
localStorage = Storage.getLocalStorageIfSupported();
buildStationList();
getCameras();
timer = new Timer() {
@Override
public void run() {
getFlowData();
timer = null;
}
};
timer.schedule(250);
if (Consts.ANALYTICS_ENABLED) {
analytics.trackView("/Seattle");
}
panel.setWidget(view);
}
示例2: TacomaViewGwtImpl
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public TacomaViewGwtImpl() {
mapCanvas = Canvas.createIfSupported();
flowCanvas = Canvas.createIfSupported();
cameraCanvas = Canvas.createIfSupported();
localStorage = Storage.getLocalStorageIfSupported();
touchDelegate = new TouchDelegate(cameraCanvas);
initWidget(uiBinder.createAndBindUi(this));
if (MGWT.getOsDetection().isAndroid()) {
leftFlexSpacer.setVisible(false);
} else if (MGWT.getOsDetection().isIOs()) {
leftFlexSpacer.setVisible(false);
}
getMap();
}
示例3: start
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
view = clientFactory.getTacomaView();
dbService = clientFactory.getDbService();
analytics = clientFactory.getAnalytics();
view.setPresenter(this);
localStorage = Storage.getLocalStorageIfSupported();
buildStationList();
getCameras();
getFlowData();
if (Consts.ANALYTICS_ENABLED) {
analytics.trackView("/Tacoma");
}
panel.setWidget(view);
}
示例4: get
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static String get(String prefname) {
String value = null;
// check browser session storage
Storage sessionStorage = Storage.getSessionStorageIfSupported();
if (sessionStorage != null) {
value = sessionStorage.getItem(PREFIX+prefname);
}
// check browser local storage
if (value == null) {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
value = localStorage.getItem(PREFIX+prefname);
}
}
// check map
if (value==null) {
value = localPrefMap.get(prefname);
}
return value;
}
示例5: onLoad
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@Override
public void onLoad() {
tabPanel.selectTab(0);
if (!Beans.isDesignTime()) {
Storage s = Storage.getLocalStorageIfSupported();
if (s != null) {
for (int i = 0; i < s.getLength(); i++) {
String key = s.key(i);
if ((key != null) && key.startsWith(STORAGE_KEY)) {
String name = key.substring(STORAGE_KEY.length());
storageList.addItem(name, key);
}
}
}
}
}
示例6: createLocalId
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public final static int createLocalId()
{
Storage storage = Storage.getLocalStorageIfSupported();
if( storage == null )
return 0;
int increment = 0;
String incrementString = storage.getItem( LOCAL_CURRENT_ID_INCREMENT );
try
{
increment = Integer.parseInt( incrementString );
}
catch( Exception e )
{
}
increment += 1;
storage.setItem( LOCAL_CURRENT_ID_INCREMENT, increment + "" );
return -increment;
}
示例7: getPreferences
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@Override
public JSONObject getPreferences(String name)
{
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage == null)
return new JSONObject();
try
{
String json = localStorage.getItem(name);
return JSON.parse(json == null ? "{}" : json);
}
catch (ParseException e)
{
return new JSONObject();
}
}
示例8: loadFromHTML5Localstore
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static FavouriteBusStationList loadFromHTML5Localstore()
{
FavouriteBusStationList favouriteBusStationList = new FavouriteBusStationList();
final Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null)
{
String tmp = localStorage.getItem(SASAbusHTML5_FAVOURITES);
if (tmp != null && tmp.length() > 0)
{
GWTStructure gwtStructure = new GWTStructure((JSONObject) JSONParser.parse(tmp));
FavouriteBusStationListUnmarshaller unmarshaller = new FavouriteBusStationListUnmarshaller();
try
{
unmarshaller.unmarschall(gwtStructure, favouriteBusStationList);
}
catch (Exception e)
{
SASAbusHTML5.handleException(e);
}
}
}
return favouriteBusStationList;
}
示例9: writeToHTML5Localstore
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public void writeToHTML5Localstore()
{
final Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null)
{
JSONStructure jsonStructure = new JSONStructure(0);
try
{
new FavouriteBusStationListMarshaller().marschall(this, jsonStructure);
String tmp = jsonStructure.toString();
localStorage.setItem(SASAbusHTML5_FAVOURITES, tmp);
}
catch (Exception e)
{
SASAbusHTML5.handleException(e);
}
}
}
示例10: loadSettingsFromLocalStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
/**
* Loads the configurable settings from localstorage. The settings are
* "updateNowMessage" for specifying the message to show when a new version
* of the cache is ready, and "updateCheckInterval" for specifying how often
* to check for new versions.
*/
private void loadSettingsFromLocalStorage() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
String newMessage = localStorage.getItem(UPDATE_NOW_MSG_KEY);
if (newMessage != null && !newMessage.isEmpty()) {
updateNowMessage = newMessage;
}
String updateCheckIntervalStr = localStorage
.getItem(UPDATE_CHECK_INTERVAL_KEY);
if (updateCheckIntervalStr != null
&& !updateCheckIntervalStr.isEmpty()) {
// The value in local storage is in seconds, but we need
// milliseconds.
updateCheckInterval = Integer.valueOf(updateCheckIntervalStr) * 1000;
}
}
}
示例11: setItem
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
@Override
public void setItem(String key, String data,
int callback) {
boolean supported = isSupported();
String oldData = null;
if (supported) {
Storage s = Storage.getLocalStorageIfSupported();
oldData = s.getItem(key);
if (data != null) {
s.setItem(key, data);
} else {
s.removeItem(key);
}
}
if (callback > -1) {
serverRpc.callLocalStorageItemCallback(callback, supported, key, oldData, data);
}
}
示例12: onModuleLoad
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public void onModuleLoad() {
PublishSubject<String> query = PublishSubject.create();
TextBox text = new TextBox(); RootPanel.get().add(text);
text.addValueChangeHandler(e -> query.onNext(e.getValue()));
Button search = new Button("search"); RootPanel.get().add(search);
search.addClickHandler(e -> query.onNext(text.getValue()));
ListBox url = new ListBox(); RootPanel.get().add(url);
url.addItem(NOMINATIM_OPENSTREETMAP);
url.addItem("http://localhost:8080/");
url.addChangeHandler(e -> query.onNext(text.getValue()));
FlowPanel results = new FlowPanel(); RootPanel.get().add(results);
// remember last selected server
Storage storage = Storage.getLocalStorageIfSupported();
if (storage != null) {
try {
url.setSelectedIndex(Integer.valueOf(storage.getItem("nominatim.url")));
} catch (Exception ignore) {}
url.addChangeHandler(c -> storage.setItem("nominatim.url", Integer.toString(url.getSelectedIndex())));
}
// on each tick, re-configure root resource and fire new request
query.switchMap(q -> {
results.clear();
if (q == null || q.isEmpty()) return Observable.empty();
Nominatim nominatim = new Nominatim_RestServiceModel(() -> osm(url.getSelectedItemText()));
return nominatim.search(q, "json").doOnNext(n -> results.add(new Label(
"[" + (int) (n.importance * 10.) + "] " + n.display_name + " (" + n.lon + "," + n.lat + ")")));
}).retry((cnt, err) -> {
GWT.log("request error: " + err, err); return true;
}).subscribe();
// fires initial search
text.setValue("Málaga,España", true);
}
示例13: getUniqueId
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
public static String getUniqueId() {
Storage storage = Storage.getLocalStorageIfSupported();
String id = storage.getItem("tech_unique_id");
if (id != null) {
return id;
}
Random rnd = new Random();
id = "";
for (int i = 0; i < 128; i++) {
id += ((char) ('a' + rnd.nextInt('z' - 'a')));
}
storage.setItem("tech_unique_id", id);
return id;
}
示例14: getOptionFromStorage
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
boolean getOptionFromStorage(String key, boolean val) {
Storage stor = Storage.getLocalStorageIfSupported();
if (stor == null)
return val;
String s = stor.getItem(key);
if (s == null)
return val;
return s == "true";
}
示例15: saveField
import com.google.gwt.storage.client.Storage; //导入方法依赖的package包/类
protected void saveField(String field, String value) {
if (Storage.isLocalStorageSupported()) {
Storage storage = Storage.getLocalStorageIfSupported();
storage.setItem(field, value);
} else {
saveCookie(value, field);
}
}