Beispiel #1
0
(function() {

	//determine platform and form factor and render approproate components
	var osname  = Ti.Platform.osname,
		version = Ti.Platform.version,
		height  = Ti.Platform.displayCaps.platformHeight,
		width   = Ti.Platform.displayCaps.platformWidth;

	//considering tablet to have one dimension over 900px - this is imperfect, so you should feel free to decide
	//yourself what you consider a tablet form factor for android
	var isAndroid = osname === 'android';
	var isTablet  = osname === 'ipad' || (isAndroid && (width > 899 || height > 899));

	// OAuth Consumer Key/Secret Key load
	//   key.js
	//   >exports.consumerKey    = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
	//   >exports.consumerSecret = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy';
	//   >[EOF]
	var key = { consumerKey:'', consumerSecret:'' };
	try {
		key = require('key');
	} catch(e) {}

	var tumblr = require('tumblr').Tumblr({
			consumerKey:       key.consumerKey,
			consumerSecret:    key.consumerSecret,
			accessTokenKey:    Ti.App.Properties.getString('tumblrAccessTokenKey',    ''),
			accessTokenSecret: Ti.App.Properties.getString('tumblrAccessTokenSecret', '')
		});

	var lib = require('lib');
	lib.Log.setLogLevel(lib.Log.LEVEL_NONE);

	var dashboard = require('tumblrDashboard').Dashboard(tumblr);

	var tabGroup = Ti.UI.createTabGroup();

	// メインウインドウ構築
	var Window = require('ui/common/MainWindow');
	var wnd = new Window(dashboard);

	var mainTab = Ti.UI.createTab({ window: wnd });
	wnd.containingTab = mainTab;
	tabGroup.addTab(mainTab);
	if (wnd.hideTabBar) {
		wnd.hideTabBar();
	}

	var actInd = Titanium.UI.createActivityIndicator({
		bottom:10, 
		height:50,
		width: 150
	});
	if (Ti.UI.iPhone) {
		actInd.style = Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN;
	}

	wnd.add(actInd);

	dashboard.addEventListener('beforeLogin', function() {
//			actInd.message = 'Logging in ...';
//			actInd.show();
		});

	dashboard.addEventListener('login', function(e) {
			// toast表示
			if (isAndroid) {
				Ti.UI.createNotification({
						message: e.success ? 'ログイン成功' : 'ログイン失敗'
					}).show();
			}
			//
			if (e.success) {
			}
			else {
			}
//			actInd.hide();
		});

	wnd.addEventListener('open', function(e) {
		});

	wnd.open();

})();
 function loginSuccessHandler (data) {
     activityIndicator.hide();
     mainWindow = new MainWindow({controller: controller});
     mainWindow.open();
     self.close();
 }