13 Apr 2016

git - simple guide

1. Setup :- 
(a) git-osx-installer
(b) git-for-windows
(c) git-for-linux


2. Create a new local repository :-
create a new directory, open it and perform a
git init :- to create a new git repository.

3. Checkout a repository :-
Create a working copy of a local repository:
git clone /path/to/repository
For a remote server, use:
git clone username@host:/path/to/repository

4. Add & commit :-
Add one or more files to staging (index):
git add *
Commit changes to head (but not yet to the remote repository):
git commit -m "Commit message"

5. Pushing changes :-
Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute :
git status :- List the files you've changed and those you still need to add or commit:
git pull origin master : - if conflict , resolve conflict and again follow step no 4. then push the code.
git push origin master :- push the code to your remote repository.

6. Branching :-
Branches are used to develop features isolated from each other. The master branch is the "default" branch when you create a repository.
Create a new branch and switch to it: git checkout -b branchname
Switch from one branch to another: git checkout branchname
List all the branches in your repository, and also tell you what branch you're currently in: git branch
Delete the feature branch: git branch -d branchname
Push the branch to your remote repository, so others can use it: git push origin branchname
Push all branches to your remote repository: git push --all origin
Delete a branch on your remote repository: git push origin :branchname

7. Update & merge :-
Fetch and merge changes on the remote server to your working directory: git pull
To merge a different branch into your active branch: git merge branchname
if conflict, resolve conflict and again follow step no 4. then push the code in your remote repository.

Read More !

6 Apr 2016

Get screen dimensions in pixels

If you want the display dimensions in pixels you can use getSize :
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

If you're not in an Activity you can get the default Display via WINDOW_SERVICE:
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();

Before getSize was introduced (in API level 13), you could use the getWidth and getHeight methods that are now deprecated:
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth(); // deprecated
int height = display.getHeight(); // deprecated

For the use case you're describing however, a margin/padding in the layout seems more appropriate.
Another ways is: DisplayMetrics.
A structure describing general information about a display, such as its size, density, and font scaling. To access the DisplayMetrics members, initialize an object like this:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
Log.d("ApplicationTagName", "Display width in px is " + metrics.widthPixels);

We can use widthPixels to get information for:
"The absolute width of the display in pixels."
Example:

Log.d("ApplicationTagName", "Display width in px is " + metrics.widthPixels);

Read More !