use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class DefaultLookAndFeel method getPullToRefreshHeight.
/**
* {@inheritDoc}
*/
public int getPullToRefreshHeight() {
if (pull == null) {
BorderLayout bl = new BorderLayout();
bl.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE);
pull = new Container(bl);
}
if (pullDown == null) {
pullDown = new Label(getUIManager().localize("pull.down", "Pull down do refresh..."));
pullDown.setUIID("PullToRefresh");
Image i = UIManager.getInstance().getThemeImageConstant("pullToRefreshImage");
if (i == null) {
i = getDefaultRefreshIcon();
}
i = i.rotate(180);
((Label) pullDown).setIcon(i);
}
if (releaseToRefresh == null) {
releaseToRefresh = new Label(getUIManager().localize("pull.release", "Release to refresh..."));
releaseToRefresh.setUIID("PullToRefresh");
Image i = UIManager.getInstance().getThemeImageConstant("pullToRefreshImage");
if (i == null) {
i = getDefaultRefreshIcon();
}
((Label) releaseToRefresh).setIcon(i);
}
if (updating == null) {
updating = new Container(new BoxLayout(BoxLayout.X_AXIS));
((Container) updating).addComponent(new InfiniteProgress());
Label l = new Label(getUIManager().localize("pull.refresh", "Updating..."));
l.setUIID("PullToRefresh");
((Container) updating).addComponent(l);
pull.getUnselectedStyle().setPadding(0, 0, 0, 0);
pull.getUnselectedStyle().setMargin(0, 0, 0, 0);
pull.addComponent(BorderLayout.CENTER, updating);
pull.layoutContainer();
pull.setHeight(Math.max(pullDown.getPreferredH(), pull.getPreferredH()));
}
String s = UIManager.getInstance().getThemeConstant("pullToRefreshHeight", null);
if (s != null) {
float f = Util.toFloatValue(s);
if (f > 0) {
return Display.getInstance().convertToPixels(f);
}
}
return pull.getHeight();
}
use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class PreviewInSimulator method main.
/**
* Called back from simulateDeviceActionPerformed to show the simulator skin
*/
public static void main(String[] argv) {
com.codename1.ui.Display.init(new Runnable() {
public void run() {
try {
Preferences pref = Preferences.userNodeForPackage(PreviewInSimulator.class);
String theme = pref.get("previewTheme", null);
File resFile = new File(pref.get("previewResource", null));
String baseResDir = pref.get("baseResourceDir", null);
if (baseResDir != null) {
JavaSEPort.setBaseResourceDir(new File(baseResDir));
}
String selection = pref.get("previewSelection", null);
Resources res = Resources.open(new FileInputStream(resFile));
if (theme == null || theme.length() == 0) {
if (com.codename1.ui.Display.getInstance().hasNativeTheme()) {
com.codename1.ui.Display.getInstance().installNativeTheme();
}
} else {
com.codename1.ui.plaf.UIManager.getInstance().setThemeProps(res.getTheme(theme));
}
com.codename1.ui.util.UIBuilder.registerCustomComponent("Table", com.codename1.ui.table.Table.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MediaPlayer", com.codename1.components.MediaPlayer.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ContainerList", com.codename1.ui.list.ContainerList.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ComponentGroup", com.codename1.ui.ComponentGroup.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Tree", com.codename1.ui.tree.Tree.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("HTMLComponent", com.codename1.ui.html.HTMLComponent.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("RSSReader", com.codename1.components.RSSReader.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("FileTree", com.codename1.components.FileTree.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("WebBrowser", com.codename1.components.WebBrowser.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("NumericSpinner", com.codename1.ui.spinner.NumericSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("DateSpinner", com.codename1.ui.spinner.DateSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("TimeSpinner", com.codename1.ui.spinner.TimeSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("DateTimeSpinner", com.codename1.ui.spinner.DateTimeSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("GenericSpinner", com.codename1.ui.spinner.GenericSpinner.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("LikeButton", com.codename1.facebook.ui.LikeButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("InfiniteProgress", com.codename1.components.InfiniteProgress.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiButton", com.codename1.components.MultiButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanButton", com.codename1.components.SpanButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("SpanLabel", com.codename1.components.SpanLabel.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Ads", com.codename1.components.Ads.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MapComponent", com.codename1.maps.MapComponent.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("MultiList", com.codename1.ui.list.MultiList.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ShareButton", com.codename1.components.ShareButton.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("OnOffSwitch", com.codename1.components.OnOffSwitch.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("ImageViewer", com.codename1.components.ImageViewer.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("AutoCompleteTextField", com.codename1.ui.AutoCompleteTextField.class);
com.codename1.ui.util.UIBuilder.registerCustomComponent("Picker", com.codename1.ui.spinner.Picker.class);
com.codename1.ui.util.UIBuilder builder = new com.codename1.ui.util.UIBuilder();
com.codename1.ui.Container c = builder.createContainer(res, selection);
if (c instanceof com.codename1.ui.Form) {
((com.codename1.ui.Form) c).refreshTheme();
if (c instanceof com.codename1.ui.Dialog) {
((com.codename1.ui.Dialog) c).showModeless();
} else {
((com.codename1.ui.Form) c).show();
}
} else {
com.codename1.ui.Form f = new com.codename1.ui.Form();
f.setLayout(new com.codename1.ui.layouts.BorderLayout());
f.addComponent(com.codename1.ui.layouts.BorderLayout.CENTER, c);
f.refreshTheme();
f.show();
}
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Error While Running In Simulator: " + ex, "Error", JOptionPane.ERROR_MESSAGE);
}
}
});
}
use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class Oauth2 method showAuthentication.
/**
* This method shows an authentication for login form
*
* @param al a listener that will receive at its source either a token for
* the service or an exception in case of a failure
* @return a component that should be displayed to the user in order to
* perform the authentication
*/
public void showAuthentication(ActionListener al) {
final Form old = Display.getInstance().getCurrent();
InfiniteProgress inf = new InfiniteProgress();
final Dialog progress = inf.showInifiniteBlocking();
Form authenticationForm = new Form("Login");
authenticationForm.setScrollable(false);
if (old != null) {
Command cancel = new Command("Cancel") {
public void actionPerformed(ActionEvent ev) {
if (Display.getInstance().getCurrent() == progress) {
progress.dispose();
}
old.showBack();
}
};
if (authenticationForm.getToolbar() != null) {
authenticationForm.getToolbar().addCommandToLeftBar(cancel);
} else {
authenticationForm.addCommand(cancel);
}
authenticationForm.setBackCommand(cancel);
}
authenticationForm.setLayout(new BorderLayout());
authenticationForm.addComponent(BorderLayout.CENTER, createLoginComponent(al, authenticationForm, old, progress));
}
use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class SignIn method showGoogleUser.
private void showGoogleUser(String token) {
ConnectionRequest req = new ConnectionRequest();
req.addRequestHeader("Authorization", "Bearer " + token);
req.setUrl("https://www.googleapis.com/plus/v1/people/me");
req.setPost(false);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
NetworkManager.getInstance().addToQueueAndWait(req);
d.dispose();
byte[] data = req.getResponseData();
JSONParser parser = new JSONParser();
Map map = null;
try {
map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8"));
} catch (IOException ex) {
ex.printStackTrace();
}
String name = (String) map.get("displayName");
Map im = (Map) map.get("image");
String url = (String) im.get("url");
Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), url);
userForm.show();
}
use of com.codename1.components.InfiniteProgress in project CodenameOne by codenameone.
the class SignIn method showFacebookUser.
private void showFacebookUser(String token) {
ConnectionRequest req = new ConnectionRequest();
req.setPost(false);
req.setUrl("https://graph.facebook.com/v2.3/me");
req.addArgumentNoEncoding("access_token", token);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
NetworkManager.getInstance().addToQueueAndWait(req);
byte[] data = req.getResponseData();
JSONParser parser = new JSONParser();
Map map = null;
try {
map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8"));
} catch (IOException ex) {
ex.printStackTrace();
}
String name = (String) map.get("name");
d.dispose();
Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), "https://graph.facebook.com/v2.3/me/picture?access_token=" + token);
userForm.show();
}
Aggregations