Responding to orientation changes in Iphone Application Using Titanium

I am learning Titanium and Just Loving it. Earlier I thought i wont be able to do many things using titanium and started learning Obj-C and Cocoa-touch framework. And that path needs lots of study and learning before someone can build something really productive.

But the Scenario is different in case of Titanium. If you have basic programming concepts and have some experience with JavaScript you can start right away after a couple hours of study. And Titanium creates the native Obj-C codes for you. So there is basically no difference in an Iphone App made with Obj-C using UIKit framework with one built using Titanium. And even better is that you can deploy your Iphone App code In Andriod Platform with few changes. Supports for Blackberry is coming. So Titanium is a very good Parser itself, it takes you code written in JavaScript And Creates the Obj-C code for Iphone and Java Code for Android for you. As Titanium acquired Aptana few days ago We can expect that we will get a very good IDE for developing Titanium Apps with code Sense, debugging features and who know what else, lets wait and see what they brings.

And the amazing thing is that it’s open source. They have an example app which have all the features Available in Iphone ranging from simple TableViews to 3D animations.

Anyway, let’s talk about the Title of this post. You know Iphone,Ipod Touch, IPad have accelerometers built-in. That means it can detect orientation changes. Now responding to orientation changes Is a very important feature that every Iphone Apps should have. Doing it is not tough with Titanium. Here is a code block, which will respond to device orientation changes by changing the UI orientation. Place it anywhere in you app.js file.

Ti.Gesture.addEventListener(
'orientationchange', function(e) {
   // alert("Called");
    win.orientationModes = [
    Titanium.UI.LANDSCAPE_LEFT,
    Titanium.UI.LANDSCAPE_RIGHT,
    Titanium.UI.PORTRAIT,
    Titanium.UI.UPSIDE_PORTRAIT
  ];
    if (e.orientation == Titanium.UI.LANDSCAPE_LEFT ||
        e.orientation == Titanium.UI.LANDSCAPE_RIGHT) {
        // Do anything you wanna do when user changes the orientation to LandScape
        Ti.UI.orientation = Titanium.UI.LANDSCAPE_RIGHT;            

    } else {
        // Revert the changes you made, the user is back to portrait mode
        Titanium.UI.orientation = Titanium.UI.PORTRAIT;
    }
});

The code is pretty straightforward. We are attaching an event listener into the Ti.Gesture and once the orientation of the device changes this callback is fired and we can do anything we want into that callback. I will try to write small posts on titanium as i go along learning Titanium.

Making Your Gp-Internet modem work with Snow Leopard

Hi guys, i got my new MacBook last month. But i was really not happy with it because i could not use internet in it. I have a gp-internet modem. It’s from HUAWEI, Model No: HUAWEI EG162G. It worked fine with Ubuntu 9.04 with zero configuration. When i got my mac, I could not even think of making it to work with Mac OSX.
But i had a hope that as it works with ubuntu there must be a way to get it to work with Snow Leopard.
Today I connected my cellphone with blue-tooth to connect to internet, but it was being disconnected after some time without any reason. then i decided to restart and go back to Win Xp installed in my MacBook and use internet with my modem.
I connected the modem and the following window poped up.

And i wanted to explore the files. I read the manual and found something written for MAC OSX and got interested. then a double clicked the installer and unfortunately it exit unexpectedly.

I was a little bit upset and Right clicked on the executable and clicked on ‘Show Package Contents’ and a window opened having a folder named ‘contents’

and opened it and then opened the ‘Resources’ folder and saw a .pkg file and i knew that it’s gonna work now.I doubled clicked on the file and the installation window appeared.

I followed the instruction and installed the driver.


then from the application folder i searched the grameen phone internet app and launched it

and clicked connect and WOW it was connected and i just opened firefox immediately and started browsing. I am getting an average speed of 12KBps and i am very much happy with it.
Thnx Rana vie for the idea of this blog post.
Enjoy ur time with MAC OSX and GP-Internet modem. Thnx GP for making this modem available in BD in such a affordable price. This is the first time i am feeling good using GP.

Got A new Apple macbook

Hi Guys,
I got my new macbook a few days ago. It’s new but refurbished. One of my friend bought me this from the US. And those who of you are planning to buy a laptop or macbook it’s better to buy it from abroad if you have the chance. Because It costs much less then it will usually cost here in Bangladesh.
Let me tell you something about the Refurbished apple products. I bought this model.

Macbook

Macbook


This is originally $999 now. But the refurb is only $849 now. And it changes depending on the availabiliy of refurbs. SO a product is considered refurbished when it’s back to apple store in either of these ways:

  1. The shippers don’t get anyone’s order.
  2. Someone return the products as there is returning facilities.
  3. The products had some very simple problem and the buyer returned it

And the list goes on………..

After a product is back Apple engineers, the test it fully replace(no repair) the defective parts and run the product cycle and after fully ensuring Apples quality it makes the product available in the refurb section. Though there are also bad experience about refurb mac products and you can find those if you google it for a while.

Anyway it’s your game whether u will buy refurb or a brand new product. But the refurb can save u as much as $200 in some models.

The one i bought from US is avaiable in Bangladesh in ComputerSource and they costs 120000BDT. So it’s only around 60000BDT more. My macbook costs $849 and US charged $74 maybe as TAX.

So if you think u need a macbook with a affordable price , i would suggest you to buy macbooks from abroad and you can risk refurbished (Hasin vie is using a refurb iMac for one year, not a single problem ) and he suggested me to a refurb mac.
And it’s better if you buy it from a country other than US, they chargesd me almost a $100 tax.You can search for a country where the tax is less.

Anyway, I am happy with my macbook and enjoying time with it. Whatever guys says Apple is this Apple is that there are some special things about Apple products and you will feel that if you use those.

That’s all for now. if you need to know anything more you can drop a comment and you can also bug in IM anytime.

Boot Slax from your USB flash drive

Slax is a lightweight linux based distro with some important features. It’s possible to boot this from a USB flash drive. Just follow the steps bellow and enjoy your time with Slax 6.0.4.
1. Download the package for flash drive from here
2. Unzip the .tar file to the root directory of your Flash drive.
3. Navigate to the boot directory of your flash drive.
4. Double click on the file bootinst.bat and follow the instruction.
5. Reboot the system and enter the boot menu to boot from the flash drive.
6. Enter the live session and install to your HDD if you like.

Enjoy your time with slax.

My first post about ACM problem

Hi, Guys this is my first post about acm problems. As this is my first post I am going to publish one of my AC code. It’s a very easy problem. But the title seems to be horrible. You just calculate the difference between the input and print the output.

The solution of problem No. 10055

The code:

//10055.cpp

#include <iostream.h>
#include<stdio.h>

int main() {
double a,b;
while (cin>>a>>b) {
if (a>b) printf(“%.0f\n”,a-b);
else printf(“%.0f\n”,b-a);
}
return 0;
}

Just copy n paste it. You will get accepted.

Started using Ubuntu 7.10

Finally I have started using Ubutu 7.10 bangla version by Ankur.  It’s just awesome with most of the necessary packages enclosed with the CD. Today I have passed 5 hour with ubuntu. And I have really enjoyed the time. I have also got all the media players and many other application with it. So it’s just excellent.