Thursday, October 13, 2011

Multiple working folders with single GIT repository clone

Actually the trick is quite trivial, we use our knowledge of git internals and unix symbolic links to achieve what we want. All we wanted is to have one repository and multiple working folders associated with it, so lets do just that.

Monday, April 4, 2011

Disable screen rotation at runtime on Android

It's strange I found no ready solution in Net...

There are two sources that help me:
http://stackoverflow.com/questions/2795833/check-orientation-on-android-phone
http://www.anddev.org/rotate_screen_from_code_change_screen_orientation-t2687.html

Finally, the next code is really works (I tested it):


public class MyActivity extends Activity {

   private int mRuntimeOrientation;
   private boolean mDisableScreenRotation;

   protected int getScreenOrientation() {
      Display display = getWindowManager().getDefaultDisplay();
      int orientation = display.getOrientation();

      if (orientation == Configuration.ORIENTATION_UNDEFINED) {
         orientation = getResources().getConfiguration().orientation;

         if (orientation == Configuration.ORIENTATION_UNDEFINED) {
            if (display.getWidth() == display.getHeight())
               orientation = Configuration.ORIENTATION_SQUARE;
            else if(display.getWidth() < display.getHeight())

               orientation = Configuration.ORIENTATION_PORTRAIT;
            else
               orientation = Configuration.ORIENTATION_LANDSCAPE;
            }
         }
      return orientation;
   }

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      mRuntimeOrientation = this.getScreenOrientation();
   }

   @Override
   public void onConfigurationChanged(Configuration newConfig) {
      if (mDisableScreenRotation) {
         super.onConfigurationChanged(newConfig);
         this.setRequestedOrientation(mRuntimeOrientation);
      } else {
         mRuntimeOrientation = this.getScreenOrientation();
         super.onConfigurationChanged(newConfig);
      }
   }
}

Thursday, March 17, 2011

C++ exceptions in destructors

Latest time while I'm looking a new job place and participating in interviews with professionals at other companies I continiously try to lighten different C++ questions...

I will post here Links to most appropriate C++ articles like previous and this ones...

C++ exceptions in destructors