Thursday 30 June 2016

fatal: Exiting because of unfinished merge. git commit error while pull/push files


Using Git Integration


Today i am going to show how to solved git merge error when two different developer work in same projects

 If some one is work in same file and both are changes in that, SO on that time we face this problem .


we have to revert any of one buddy file,

Here Some tutorial are below  :

https://www.atlassian.com/git/tutorials/



BUT By write some command we solve that Problem


git fetch origin 
git reset --hard origin/master 
git pull



Or Second thing is below . 








Prepare :

At the first, you should install Git for Windows.
And then, Setting git tools path for Android Studio.
File > Settings > Version Control > Git
You can click Test button to check function. Such as figure below.


Step 1 : Enable Version Control Integration(git init)

VCS > Enable Version Control Integration > select "Git"
And then, you will discovery that your project list changed color. Like figure.


Step 2 : Git Add Remote

In this step, Android Studio doesn't provide GUI to work, We should use Git for Windows tool.
Go find Git Bash in git folder.
  1. Git Bash > Go to Project folder
  2. Git Bash > key in add remote command
    Ex: git remote add origin git@192.168.0.1:user/android-studio-git.git

use command git gui 

using of this command we can solved our problem . 




Thanks for watching .....


Monday 14 March 2016

Butter Knife android studio example

Creating code can sometimes be frustrating. Developers have to deal with redundant coding that is visually unattractive.
In this article, I will introduce an injection library for Android development that can help create more beautiful code. Android Butter Knife is an open source view “injection” library for Android created by Jake Wharton.
Butterknife logo
The source code for the library and sample application are [available on GitHub](https://github.com/JakeWharton/butterknife](https://github.com/JakeWharton/butterknife).
Butter Knife is small, simple and lightweight, and it makes life as a developer easier. It allows developers to perform injection on arbitrary objectsviews and OnClickListeners so they can focus on writing useful code. Consider Android Butter Knife a reduction library. It replaces findViewById with @Bind()and various set^^^^Listener calls with @onClick() making code cleaner and more understandable. Butter Knife enables focus on logic rather than glue code and reduces development time by reducing redundant coding.

Setting up the Development Environment

To use Android Butter Knife in development, integrate it into a project:
Open the project’s build.gradle file.
Adding to Gradle file
Copy the following code to suppress the lint warning in build.gradle.
lintOptions {
  disable 'InvalidPackage'
}
Add the following dependency
compile 'com.jakewharton:butterknife:7.0.1'
Click Sync Now to sync the project’s Gradle files and you are ready to code with Butter Knife.

Getting started with Android Butter Knife

Which would you choose from the following blocks of code?
The standard code to find view objects in the activity_main.xml layout file.
Button button = (Button)findViewById(R.id.button);
    TextView textView = (TextView)findViewById(R.id.textView);
    RadioButton radioButton  = (RadioButton)findViewById(R.id.radioButton);
    CheckBox checkBox= (CheckBox)findViewById(R.id.checkbox);
    EditText editText = (EditText)findViewById(R.id.editText);
    VideoView videoView = (VideoView)findViewById(R.id.videoView);
    WebView webView = (WebView)findViewById(R.id.webView);
Android Butter Knife code
@Bind(R.id.button)
    Button button;
    @Bind(R.id.textView)
    TextView textView;
    @Bind(R.id.radioButton)
    RadioButton radioButton;
    @Bind(R.id.checkBox)
    CheckBox checkBox;
    @Bind(R.id.editText)
    EditText editText;
    @Bind(R.id.videoView)
    VideoView videoView;
    @Bind(R.id.webView)
    WebView webView;
I personally prefer the second block, it’s smaller and well structured. This is how Android Butter Knife improves views in the layout file.

Using Butter Knife for something useful.

The simplest piece code you are likely to use while coding for Android is a Toast Message:
@Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);

    Button button = (Button)findViewById(R.id.button);

         button.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Toast.makeText(getApplicationContext(),"Hello Android",Toast.LENGTH_LONG).show();

             }
         });

     }
This is all the code needed in the onCreate() method to create a Toast on a button click. There are a lot of parenthesis and the code is long and difficult to understand. There is an anonymous inner class inside the OnClickListener() that can be avoided by using Butter Knife.
Think of how the code would look if you had to call multiple OnClickListeners? The Activity.java file containing these listeners would be overrun with ugly code.
Here is how Butter Knife will improve this code:
@Bind(R.id.button)
    Button button;

    @OnClick(R.id.button)
    protected void Toast(){
        Toast.makeText(getApplicationContext(),"Hello Android Butter Knife",Toast.LENGTH_LONG).show();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

    }
It is clean, simple and easy to understand. In the onCreate() method, insertButterKnife.bind(this) and the anonymous inner class inside the listener is not needed.
Let’s take a look at another example:
With Android Butter Knife, multiple views can be grouped into a List or array. The apply method allows all the views in a list to be acted upon simultaneously.
This method needs two parameters, the list of views and an action to perform on the group of views. In the following code I have created a Butter Knife action CHANGE_COLOR that changes the color of the buttons and changes the of the application. The apply() method is called when button1 is clicked.
//group of multiple buttons
    @Bind({R.id.button1,R.id.button2,R.id.button3})
    List<Button> buttons;

    //the Butter Knife Action
     final ButterKnife.Action<Button> CHANGE_COLOR = new ButterKnife.Action<Button>() {

        @Override
        public void apply(Button button, int index) {

            setTitle("Code with Butter Knife");
            buttons.get(0).setBackgroundColor(Color.RED);
            buttons.get(1).setBackgroundColor(Color.RED);
            buttons.get(2).setBackgroundColor(Color.RED);
       }
   };

    @OnClick(R.id.button1)
    protected void onClick(){
        ButterKnife.apply(buttons,CHANGE_COLOR);
    //the apply method called on button1 Click
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
    }
Thank you http://www.sitepoint.com. taking hep from you.