Android Open Source - nxt-remote-controller Dialog






From Project

Back to project page nxt-remote-controller.

License

The source code is released under:

MIT License

If you think the Android project nxt-remote-controller listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.gc.materialdesign.widgets;
//from w ww  .  j a v a  2  s  . c  om
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gc.materialdesign.R;
import com.gc.materialdesign.views.ButtonFlat;

public class Dialog extends android.app.Dialog{
  
  Context context;
  View view;
  View backView;
  String message;
  TextView messageTextView;
  String title;
  TextView titleTextView;
  
  ButtonFlat buttonAccept;
  ButtonFlat buttonCancel;
  
  View.OnClickListener onAcceptButtonClickListener;
  View.OnClickListener onCancelButtonClickListener;
  

  public Dialog(Context context,String title, String message) {
    super(context, android.R.style.Theme_Translucent);
    this.context = context;// init Context
    this.message = message;
    this.title = title;
  }
  
  @Override
    protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
      super.onCreate(savedInstanceState);
      setContentView(R.layout.dialog);
      
    view = (RelativeLayout)findViewById(R.id.contentDialog);
    backView = (RelativeLayout)findViewById(R.id.dialog_rootView);
    backView.setOnTouchListener(new OnTouchListener() {
      
      @Override
      public boolean onTouch(View v, MotionEvent event) {
        if (event.getX() < view.getLeft() 
            || event.getX() >view.getRight()
            || event.getY() > view.getBottom() 
            || event.getY() < view.getTop()) {
          dismiss();
        }
        return false;
      }
    });
    
      this.titleTextView = (TextView) findViewById(R.id.title);
      setTitle(title);
      
      this.messageTextView = (TextView) findViewById(R.id.message);
      setMessage(message);
      
      this.buttonAccept = (ButtonFlat) findViewById(R.id.button_accept);
      buttonAccept.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        dismiss();
        if(onAcceptButtonClickListener != null)
            onAcceptButtonClickListener.onClick(v);
      }
    });
      this.buttonCancel = (ButtonFlat) findViewById(R.id.button_cancel);
      buttonCancel.setOnClickListener(new View.OnClickListener() {
        
      @Override
      public void onClick(View v) {
        dismiss();  
        if(onCancelButtonClickListener != null)
            onCancelButtonClickListener.onClick(v);
      }
    });
  }
  
  @Override
  public void show() {
    // TODO ??????????
    super.show();
    // set dialog enter animations
    view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_main_show_amination));
    backView.startAnimation(AnimationUtils.loadAnimation(context, R.anim.dialog_root_show_amin));
  }
  
  // GETERS & SETTERS

  public String getMessage() {
    return message;
  }

  public void setMessage(String message) {
    this.message = message;
    messageTextView.setText(message);
  }

  public TextView getMessageTextView() {
    return messageTextView;
  }

  public void setMessageTextView(TextView messageTextView) {
    this.messageTextView = messageTextView;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
    if(title == null)
      titleTextView.setVisibility(View.GONE);
    else{
      titleTextView.setVisibility(View.VISIBLE);
      titleTextView.setText(title);
    }
  }

  public TextView getTitleTextView() {
    return titleTextView;
  }

  public void setTitleTextView(TextView titleTextView) {
    this.titleTextView = titleTextView;
  }

  public ButtonFlat getButtonAccept() {
    return buttonAccept;
  }

  public void setButtonAccept(ButtonFlat buttonAccept) {
    this.buttonAccept = buttonAccept;
  }

  public ButtonFlat getButtonCancel() {
    return buttonCancel;
  }

  public void setButtonCancel(ButtonFlat buttonCancel) {
    this.buttonCancel = buttonCancel;
  }

  public void setOnAcceptButtonClickListener(
      View.OnClickListener onAcceptButtonClickListener) {
    this.onAcceptButtonClickListener = onAcceptButtonClickListener;
    if(buttonAccept != null)
      buttonAccept.setOnClickListener(onAcceptButtonClickListener);
  }

  public void setOnCancelButtonClickListener(
      View.OnClickListener onCancelButtonClickListener) {
    this.onCancelButtonClickListener = onCancelButtonClickListener;
    if(buttonCancel != null)
      buttonCancel.setOnClickListener(onAcceptButtonClickListener);
  }
  
  @Override
  public void dismiss() {
    Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination);
    anim.setAnimationListener(new AnimationListener() {
      
      @Override
      public void onAnimationStart(Animation animation) {
      }
      
      @Override
      public void onAnimationRepeat(Animation animation) {
      }
      
      @Override
      public void onAnimationEnd(Animation animation) {
        view.post(new Runnable() {
          @Override
          public void run() {
                Dialog.super.dismiss();
              }
          });
        
      }
    });
    Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin);
    
    view.startAnimation(anim);
    backView.startAnimation(backAnim);
  }
  
  

}




Java Source Code List

.OldPadControllerFragment.java
com.andexert.library.ApplicationTest.java
com.andexert.library.RippleView.java
com.andexert.rippleeffect.ApplicationTest.java
com.andexert.rippleeffect.CustomAdapter.java
com.andexert.rippleeffect.MainActivity.java
com.andexert.rippleeffect.OnTapListener.java
com.gc.materialdesign.utils.Utils.java
com.gc.materialdesign.views.ButtonFlat.java
com.gc.materialdesign.views.ButtonFloatSmall.java
com.gc.materialdesign.views.ButtonFloat.java
com.gc.materialdesign.views.ButtonIcon.java
com.gc.materialdesign.views.ButtonRectangle.java
com.gc.materialdesign.views.Button.java
com.gc.materialdesign.views.Card.java
com.gc.materialdesign.views.CheckBox.java
com.gc.materialdesign.views.CustomView.java
com.gc.materialdesign.views.LayoutRipple.java
com.gc.materialdesign.views.ProgressBarCircularIndeterminate.java
com.gc.materialdesign.views.ProgressBarDeterminate.java
com.gc.materialdesign.views.ProgressBarIndeterminateDeterminate.java
com.gc.materialdesign.views.ProgressBarIndeterminate.java
com.gc.materialdesign.views.RippleView.java
com.gc.materialdesign.views.ScrollView.java
com.gc.materialdesign.views.Slider.java
com.gc.materialdesign.views.Switch.java
com.gc.materialdesign.widgets.ColorSelector.java
com.gc.materialdesign.widgets.Dialog.java
com.gc.materialdesign.widgets.SnackBar.java
git.egatuts.nxtremotecontroller.ApplicationTest.java
git.egatuts.nxtremotecontroller.GlobalUtils.java
git.egatuts.nxtremotecontroller.activity.ActivityPendingTransition.java
git.egatuts.nxtremotecontroller.activity.BaseActivity.java
git.egatuts.nxtremotecontroller.activity.ControllerActivity.java
git.egatuts.nxtremotecontroller.activity.DefaultActivityPendingTransition.java
git.egatuts.nxtremotecontroller.activity.MainActivity.java
git.egatuts.nxtremotecontroller.activity.SettingsActivity.java
git.egatuts.nxtremotecontroller.bluetooth.BluetoothConstants.java
git.egatuts.nxtremotecontroller.bluetooth.BluetoothUtils.java
git.egatuts.nxtremotecontroller.bluetooth.NXTConnector.java
git.egatuts.nxtremotecontroller.device.PairedDeviceAdapter.java
git.egatuts.nxtremotecontroller.device.PairedDeviceItemClickListener.java
git.egatuts.nxtremotecontroller.device.PairedDeviceViewHolder.java
git.egatuts.nxtremotecontroller.device.PairedDevice.java
git.egatuts.nxtremotecontroller.exception.SocketCreationException.java
git.egatuts.nxtremotecontroller.fragment.ActivityBaseFragment.java
git.egatuts.nxtremotecontroller.fragment.BaseFragment.java
git.egatuts.nxtremotecontroller.fragment.BluetoothFragment.java
git.egatuts.nxtremotecontroller.fragment.ControllerBaseFragment.java
git.egatuts.nxtremotecontroller.fragment.DefaultFragmentPendingTransition.java
git.egatuts.nxtremotecontroller.fragment.FragmentPendingTransition.java
git.egatuts.nxtremotecontroller.fragment.HomeFragment.java
git.egatuts.nxtremotecontroller.fragment.LocalControllerFragment.java
git.egatuts.nxtremotecontroller.fragment.OnlineControllerFragment.java
git.egatuts.nxtremotecontroller.fragment.ScanFragment.java
git.egatuts.nxtremotecontroller.fragment.SettingsFragment.java
git.egatuts.nxtremotecontroller.listener.AnimationEndListener.java
git.egatuts.nxtremotecontroller.listener.AppKillerListener.java
git.egatuts.nxtremotecontroller.listener.BaseListener.java
git.egatuts.nxtremotecontroller.listener.BluetoothDiscoveryListener.java
git.egatuts.nxtremotecontroller.listener.BluetoothEnableListener.java
git.egatuts.nxtremotecontroller.listener.BluetoothPairingListener.java
git.egatuts.nxtremotecontroller.navigation.DrawerItemViewHolder.java
git.egatuts.nxtremotecontroller.navigation.DrawerItem.java
git.egatuts.nxtremotecontroller.navigation.NavigationDrawerAdapter.java
git.egatuts.nxtremotecontroller.navigation.NavigationDrawerCallback.java
git.egatuts.nxtremotecontroller.navigation.NavigationDrawerFragment.java
git.egatuts.nxtremotecontroller.preference.PreferencesUtils.java
git.egatuts.nxtremotecontroller.receiver.AppKillerReceiver.java
git.egatuts.nxtremotecontroller.receiver.BaseReceiver.java
git.egatuts.nxtremotecontroller.receiver.BluetoothDiscoveryReceiver.java
git.egatuts.nxtremotecontroller.receiver.BluetoothEnableReceiver.java
git.egatuts.nxtremotecontroller.receiver.BluetoothPairingReceiver.java
git.egatuts.nxtremotecontroller.thread.BaseThread.java
git.egatuts.nxtremotecontroller.thread.ConnectThread.java
git.egatuts.nxtremotecontroller.thread.ConnectedThread.java
git.egatuts.nxtremotecontroller.views.BaseIndeterminateProgressDialog.java
git.egatuts.nxtremotecontroller.views.BaseProgressDialog.java
git.egatuts.nxtremotecontroller.views.JoystickView.java
git.egatuts.nxtremotecontroller.views.LongIndeterminateProgressDialog.java
git.egatuts.nxtremotecontroller.views.ShortIndeterminateProgressDialog.java