2 Jan 2015

Custom dialog with animation | Dialog effect Android

There are no any application available without alert massages,Generally we are using AlertDialog of android for Alert.

In this tutorial, you can achieve much more using dialog as per your desire like
-Set theme for dialog
-Set custom view in dialog
-Animations for dialog

Animation Effects :
Fadein, Slideleft, Slidetop, SlideBottom, Slideright, Fall, Newspager, Fliph, Flipv, RotateBottom, RotateLeft, Slit, Shake, Sidefill

For more visualization (See the Effect)

OUTPUT SCREEN :




Here is the implementation :

MainActivity :


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import com.hb.lib.CustomDialogBuilder;
import com.hb.lib.Effectstype;

public class MainActivity extends Activity
{
       private Effectstype effect;

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

       public void dialogShow(View v)
       {
              CustomDialogBuilder dialogBuilder=CustomDialogBuilder.getInstance(this);

              switch (v.getId())
              {
              case R.id.fadein:effect=Effectstype.Fadein;break;
              case R.id.slideright:effect=Effectstype.Slideright;break;
              case R.id.slideleft:effect=Effectstype.Slideleft;break;
              case R.id.slidetop:effect=Effectstype.Slidetop;break;
              case R.id.slideBottom:effect=Effectstype.SlideBottom;break;
              case R.id.newspager:effect=Effectstype.Newspager;break;
              case R.id.fall:effect=Effectstype.Fall;break;
              case R.id.sidefall:effect=Effectstype.Sidefill;break;
              case R.id.fliph:effect=Effectstype.Fliph;break;
              case R.id.flipv:effect=Effectstype.Flipv;break;
              case R.id.rotatebottom:effect=Effectstype.RotateBottom;break;
              case R.id.rotateleft:effect=Effectstype.RotateLeft;break;
              case R.id.slit:effect=Effectstype.Slit;break;
              case R.id.shake:effect=Effectstype.Shake;break;
              }

              dialogBuilder
              .withTitle("Alert Dialog")                           
              .withTitleColor("#FFFFFF")                           
              .withDividerColor("#cfdde7")                         
              .withMessage("This is a Dialog.")                    
              .withMessageColor("#FFFFFFFF")                           
              .withDialogColor("#264461")                              
              .withIcon(getResources().getDrawable(R.drawable.icon))
              .isCancelableOnTouchOutside(true)                         
              .withDuration(700)                                        
              .withEffect(effect)                                        
              .withButton1Text("OK")                                     
              .withButton2Text("Cancel")                                  
              .setCustomView(R.layout.custom_view,v.getContext()) 

              .setButton1Click(new View.OnClickListener()
              {
                     @Override
                     public void onClick(View v)
                     {
                           Toast.makeText(v.getContext(), "Press OK button", Toast.LENGTH_SHORT).show();
                     }
              })
              .setButton2Click(new View.OnClickListener()
              {
                     @Override
                     public void onClick(View v)
                     {
                           Toast.makeText(v.getContext(), "Press Cancel button", Toast.LENGTH_SHORT).show();
                     }
              })
              .show();

       }


}

Download Library & Sample :  DialogEffectSample

I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)

31 Dec 2014

ActionSheet like IOS in Android

Hello Friends,

Here is the tutorial for Action Sheet like IOS in Android

OUTPUT SCREEN :




MainActivity :


import com.hb.actionsheet.R;
import com.hb.actionsheet.ActionSheet.ActionSheetListener;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends FragmentActivity implements ActionSheetListener
{
       @Override
       protected void onCreate(Bundle savedInstanceState)
       {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
       }

       public void onClick(View v)
       {
              switch (v.getId())
              {
              case R.id.ios6:
                     setTheme(R.style.ActionSheetStyleIOS6);
                     break;
              case R.id.ios7:
                     setTheme(R.style.ActionSheetStyleIOS7);
                     break;
              }
              showActionSheet();
       }

       public void showActionSheet()
       {
              ActionSheet.createBuilder(this, getSupportFragmentManager())
              .setCancelButtonTitle("Cancel")
              .setOtherButtonTitles("Add", "Delete", "Edit")
              .setCancelableOnTouchOutside(true).setListener(this).show();
       }

       @Override
       public void onOtherButtonClick(ActionSheet actionSheet, int index)
       {
              Toast.makeText(getApplicationContext(), "click item index = " + index,
                           0).show();
       }

       @Override
       public void onDismiss(ActionSheet actionSheet, boolean isCancle)
       {
              Toast.makeText(getApplicationContext(), "dismissed isCancle = " + isCancle, 0).show();
       }


}


Download Sample Code :  ActionsheetSample

I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)