Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 10th, 2012  |  syntax: None  |  size: 6.43 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class Availability extends Activity implements OnClickListener,
  2.         OnCheckedChangeListener {
  3.     ToggleButton override;
  4.     TextView status;
  5.     Button Overridestatus;
  6.     CharSequence[] choice = { "RemoteOffice", "Office", "Personal mobile",
  7.             "Home", "Mobile", "Temporary", "Do not Disturb",
  8.             "Working Remotely", "Non work day", "Work Day" };
  9.     RadioGroup timeperiod;
  10.     TimePicker timePicker;
  11.     int hour, minute;
  12.  
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         // TODO Auto-generated method stub
  16.         super.onCreate(savedInstanceState);
  17.         setContentView(R.layout.availability);
  18.         override = (ToggleButton) findViewById(R.id.tbOver);
  19.         override.setOnClickListener(this);
  20.         status = (TextView) findViewById(R.id.tvstatus);
  21.         Overridestatus = (Button) findViewById(R.id.bstatus);
  22.         Overridestatus.setOnClickListener(this);
  23.         timeperiod = (RadioGroup) findViewById(R.id.rgtimeperiod);
  24.         timeperiod.setOnCheckedChangeListener(this);
  25.         timePicker = (TimePicker) findViewById(R.id.timePicker);
  26.         timePicker.setIs24HourView(true);
  27.  
  28.     }
  29.  
  30.     public void onClick(View view) {
  31.         // TODO Auto-generated method stub
  32.         switch (view.getId()) {
  33.         case R.id.tbOver:
  34.  
  35.             if (override.isChecked()) {
  36.  
  37.                 status.setText("Override");
  38.                 Overridestatus.setText("Personal Mobile");
  39.  
  40.             } else {
  41.                 status.setText("Currently");
  42.                 Overridestatus.setText("Use Schedule - Do Not Disturb");
  43.  
  44.             }
  45.             break;
  46.  
  47.         case R.id.bstatus:
  48.  
  49.         {
  50.             if (override.isChecked()) {
  51.                 showDialog(0);
  52.             }
  53.         }
  54.  
  55.             break;
  56.         case R.id.rhrandmin:
  57.         }
  58.     }
  59.  
  60.     @Override
  61.     protected Dialog onCreateDialog(int id) {
  62.         // TODO Auto-generated method stub
  63.         switch (id) {
  64.         case 0:
  65.             AlertDialog.Builder builder = new AlertDialog.Builder(this);
  66.             builder.setTitle("Select System Server");
  67.             builder.setIcon(R.drawable.ic_btn_round_more_normal);
  68.             builder.setPositiveButton("OK",
  69.                     new DialogInterface.OnClickListener() {
  70.  
  71.                         public void onClick(DialogInterface dialog, int id) {
  72.                             // TODO Auto-generated method stub
  73.                             Intent menu = new Intent(Availability.this,
  74.                                     MenuScreen.class);
  75.                             startActivity(menu);
  76.  
  77.                         }
  78.                     });
  79.             builder.setNegativeButton("CANCEL",
  80.                     new DialogInterface.OnClickListener() {
  81.  
  82.                         public void onClick(DialogInterface dialog, int which) {
  83.                             // TODO Auto-generated method stub
  84.  
  85.                         }
  86.                     });
  87.  
  88.             builder.setSingleChoiceItems(choice, -1,
  89.                     new DialogInterface.OnClickListener() {
  90.  
  91.                         public void onClick(DialogInterface dialog, int item) {
  92.                             // TODO Auto-generated method stub
  93.  
  94.                         }
  95.                     });
  96.  
  97.             builder.create();
  98.             builder.show();
  99.             break;
  100.         case 2:
  101.              new TimePickerDialog(this, mTimeSetListener, hour, minute,false);
  102.             break;
  103.         }
  104.  
  105.         return null;
  106.  
  107.     }
  108.  
  109.     private TimePickerDialog.OnTimeSetListener mTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
  110.         public void onTimeSet(TimePicker view, int hourOfDay, int minuteOfHour) {
  111.             hour = hourOfDay;
  112.             minute = minuteOfHour;
  113.             Toast.makeText(getBaseContext(),
  114.                     "You have selected : " + hour + ":" + minute,
  115.                     Toast.LENGTH_SHORT).show();
  116.         }
  117.     };
  118.  
  119.     public void onCheckedChanged(RadioGroup group, int checkedId) {
  120.         // TODO Auto-generated method stub
  121.         switch (checkedId) {
  122.         case R.id.ridefinate:
  123.  
  124.             break;
  125.  
  126.         case R.id.rdays:
  127.  
  128.             break;
  129.         case R.id.rhrandmin:
  130.         //  showDialog(2);
  131.             break;
  132.         case R.id.rtilldate:
  133.              showDialog(1);
  134.             break;
  135.         }
  136.     }
  137.  
  138. }
  139.        
  140. 10-16 19:16:16.567: E/AndroidRuntime(1137): FATAL EXCEPTION: main
  141. 10-16 19:16:16.567: E/AndroidRuntime(1137): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.avst.callxpressmobile/com.example.avst.callxpressmobile.Availability}: java.lang.NullPointerException
  142. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
  143. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  144. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.ActivityThread.access$600(ActivityThread.java:130)
  145. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  146. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.os.Handler.dispatchMessage(Handler.java:99)
  147. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.os.Looper.loop(Looper.java:137)
  148. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.ActivityThread.main(ActivityThread.java:4745)
  149. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at java.lang.reflect.Method.invokeNative(Native Method)
  150. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at java.lang.reflect.Method.invoke(Method.java:511)
  151. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  152. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  153. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at dalvik.system.NativeStart.main(Native Method)
  154. 10-16 19:16:16.567: E/AndroidRuntime(1137): Caused by: java.lang.NullPointerException
  155. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at com.example.avst.callxpressmobile.Availability.onCreate(Availability.java:47)
  156. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.Activity.performCreate(Activity.java:5008)
  157. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  158. 10-16 19:16:16.567: E/AndroidRuntime(1137):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  159. 10-16 19:16:16.567: E/AndroidRuntime(1137):     ... 11 more