private void InitState() {
    // title
    String sSubTitle = utils.GetResStr(R.string.titleDefaultAppointment);

    // date values
    dateStart = Calendar.getInstance();
    dateEndOn = Calendar.getInstance();

    dataRow.SetDuration(prefs.iMinutesDuration);

    // INSERT MODE
    if (GetStartMode() == StartMode.NEW) {
      sSubTitle = utils.GetResStr(R.string.titleNewAppointment);
      btnDelete.setVisibility(View.INVISIBLE);

      // initialize data
      SetStartDateByAgendaView(dateStart);
      updateStartDateTimeForNewAppointment(dateStart);
      SetStartTimeForDayAgendaView(dateStart);

      chkAllDay.setChecked(false);
      chkAlarm.setChecked(true);

      // repeat data
      iRepeatType = 0; // none
      iRepeatEvery = 1;
      dateEndOn.setTimeInMillis(0); // no end date
    }

    // EDIT MODE
    if (GetStartMode() == StartMode.EDIT) {
      sSubTitle = utils.GetResStr(R.string.titleEditAppointment);

      dateStart.setTimeInMillis(dataRow.GetStartDate().getTimeInMillis());

      btnDelete.setVisibility(View.VISIBLE);
      edSubject.setText(dataRow.GetSubject());
      chkAllDay.setChecked(dataRow.GetAllDay());
      chkAlarm.setChecked(dataRow.GetAlarm());

      // repeat data
      iRepeatType = dataRow.GetRepeat().GetRepeatTypeAsInt();
      iRepeatEvery = dataRow.GetRepeat().GetEvery();
      dateEndOn.setTimeInMillis(dataRow.GetRepeat().GetEndOnDate().getTimeInMillis());
    }

    restoreStateFromFreezeIfRequired();

    SetActivityTitle(sSubTitle);
    UpdateStartDateTimeView();

    UpdateRepeatInfo();

    // set focus to subject
    edSubject.requestFocus();
    if (GetStartMode() == StartMode.EDIT) edSubject.setSelection(edSubject.length());
  }
示例#2
0
  private void InitViews() {
    edSubject = (TouchEdit) findViewById(R.id.edCourseSubject);
    btnStartDate = (Button) findViewById(R.id.btnCourseStartDate);
    btnStartTime = (Button) findViewById(R.id.btnCourseStartTime);
    btnStartDate.setVisibility(ImageButton.VISIBLE);
    btnRepeatSelect = (Button) findViewById(R.id.btnRepeatSelect);
    btnRepeatSelect.setVisibility(ImageButton.INVISIBLE);
    btnStartDate.setVisibility(ImageButton.GONE);

    btnSave = (ImageButton) findViewById(R.id.btnCourseSave);
    btnSave.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            SaveData();
          }
        });

    btnDelete = (ImageButton) findViewById(R.id.btnCourseDelete);
    btnDelete.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            DeleteData();
          }
        });
  }
示例#3
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   drawView = (DrawingView) findViewById(R.id.drawing);
   smallBrush = getResources().getInteger(R.integer.small_size);
   mediumBrush = getResources().getInteger(R.integer.medium_size);
   largeBrush = getResources().getInteger(R.integer.large_size);
   drawBtn = (ImageButton) findViewById(R.id.draw_btn);
   drawBtn.setOnClickListener(this);
   drawView.setBrushSize(mediumBrush);
   eraseBtn = (ImageButton) findViewById(R.id.erase_btn);
   eraseBtn.setOnClickListener(this);
   newBtn = (ImageButton) findViewById(R.id.new_btn);
   newBtn.setOnClickListener(this);
   equalsBtn = (ImageButton) findViewById(R.id.equals_btn);
   equalsBtn.setOnClickListener(this);
 }
示例#4
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onCreate(savedInstanceState);
   setContentView(R.layout.snap);
   initialcam();
   // fixing for initialising an initial value for bmp via inputstream
   InputStream i = getResources().openRawResource(R.drawable.ic_launcher);
   bmp = BitmapFactory.decodeStream(i);
   ib.setOnClickListener(this);
   bton.setOnClickListener(this);
 }
示例#5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    setContentView(R.layout.main);

    getActionBar().setDisplayShowTitleEnabled(true);
    getActionBar().setHomeButtonEnabled(false);

    final ImageButton startButton = (ImageButton) findViewById(R.id.startButton);
    startButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            new UpdateActionsAsyncTask().execute();
          }
        });

    startPane = findViewById(R.id.startPane);
    statusLabel = (TextView) findViewById(R.id.statusLabel);
  }
示例#6
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    this.deviceInfo = getDeviceInfoFromApplicationContext();

    StopWatch sw = new StopWatch();
    sw.start("create activity");

    createAnimation();
    buildFadeInPageViewAnimation();
    buildFadeOutPageViewAnimation();

    setProgressBarIndeterminateVisibility(false);
    System.out.println("debug on create");

    executor =
        new ThreadPoolExecutor(
            0, Integer.MAX_VALUE, 10L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
    sourceDB = new SourceDB(this);
    alarmSender = new AlarmSender(this);

    //        sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    //        acceleromererSensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    //        createShakeListener();

    Cursor sourceCursor = sourceDB.findAll();

    startManagingCursor(sourceCursor);

    sourceAdapter =
        new SourceItemArrayAdapter<SourceItem>(this, R.layout.source_item, sourceDB, deviceInfo);

    TelephonyManager tManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
    deviceId = tManager.getDeviceId();
    inflater = LayoutInflater.from(this);
    accountType = (String) getIntent().getExtras().get("type");
    sourceId = (String) getIntent().getExtras().get("sourceId");
    sourceImageURL = (String) getIntent().getExtras().get("sourceImage");
    sourceName = (String) getIntent().getExtras().get("sourceName");
    contentUrl = (String) getIntent().getExtras().get("contentUrl");

    //// System.out.println("sourceImageURL:" + sourceImageURL);
    setContentView(R.layout.main);
    container = (ViewGroup) findViewById(R.id.pageContainer);
    pageIndexView = (PageIndexView) findViewById(R.id.pageIndex);
    ViewSwitcher headerSwitcher = (ViewSwitcher) findViewById(R.id.flipper);
    header = (HeaderView) findViewById(R.id.header);
    contentImageButton = (ImageButton) findViewById(R.id.content);
    contentImageButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            overridePendingTransition(android.R.anim.slide_in_left, R.anim.fade);
            PageActivity.this.finish();
          }
        });
    //        pageInfo = (TextView)header.findViewById(R.id.pageInfo);
    headerText = (TextView) findViewById(R.id.headerText);
    headerImageView = (WebImageView) findViewById(R.id.headerImage);

    pageViewFactory = new WeiboPageViewFactory();

    preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    this.browseMode = getBrowseMode();
    //        this.animationMode = getAnimationMode();
    refreshingSemaphore = new Semaphore(1, true);
    Log.v("accountType", accountType);
    reload();
  }
  private void InitViews() {
    edSubject = (TouchEdit) findViewById(R.id.edAppointmentSubject);
    edSubject.setOnOpenKeyboard(
        new TouchEdit.OnOpenKeyboard() {
          public void OnOpenKeyboardEvent() {
            KeyboardWidget.Open(ActivityAppointment.this, edSubject.getText().toString());
          }
        });

    btnStartDate = (Button) findViewById(R.id.btnAppointmentStartDate);
    btnStartTime = (Button) findViewById(R.id.btnAppointmentStartTime);
    chkAllDay = (CheckBox) findViewById(R.id.chkAppointmentAllDay);
    chkAlarm = (CheckBox) findViewById(R.id.chkAppointmentAlarm);

    btnRepeatSelect = (Button) findViewById(R.id.btnRepeatSelect);
    btnRepeatSelect.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            OpenRepeatDialog();
          }
        });

    btnSave = (ImageButton) findViewById(R.id.btnAppointmentSave);
    btnSave.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            SaveData();
          }
        });

    btnDelete = (ImageButton) findViewById(R.id.btnAppointmentDelete);
    btnDelete.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            DeleteData();
          }
        });

    btnStartDate.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {

            DateWidget.Open(ActivityAppointment.this, false, dateStart, prefs.iFirstDayOfWeek);
          }
        });

    btnStartTime.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {

            TimeWidget.Open(
                ActivityAppointment.this,
                false,
                prefs.b24HourMode,
                dateStart.get(Calendar.HOUR_OF_DAY),
                dateStart.get(Calendar.MINUTE));
          }
        });

    chkAllDay.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            UpdateStartDateTimeView();
          }
        });
  }
示例#8
0
 @Override
 public void onClick(View view) {
   if (view.getId() == R.id.draw_btn) {
     if (!drawView.getErase()) {
       final Dialog brushDialog = new Dialog(this);
       brushDialog.setTitle("Brush size:");
       brushDialog.setContentView(R.layout.brush_chooser);
       ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
       smallBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(smallBrush);
               drawView.setLastBrushSize(smallBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
       mediumBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(mediumBrush);
               drawView.setLastBrushSize(mediumBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
       largeBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(largeBrush);
               drawView.setLastBrushSize(largeBrush);
               brushDialog.dismiss();
             }
           });
       brushDialog.show();
     }
     drawView.setErase(false);
   } else if (view.getId() == R.id.erase_btn) {
     if (drawView.getErase()) {
       final Dialog brushDialog = new Dialog(this);
       brushDialog.setTitle("Eraser size:");
       brushDialog.setContentView(R.layout.brush_chooser);
       ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
       smallBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(smallBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
       mediumBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(mediumBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
       largeBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(largeBrush);
               brushDialog.dismiss();
             }
           });
       brushDialog.show();
     }
     drawView.setErase(true);
   } else if (view.getId() == R.id.new_btn) {
     AlertDialog.Builder newDialog = new AlertDialog.Builder(this);
     newDialog.setTitle("New equation");
     newDialog.setMessage("Start new equation?");
     newDialog.setPositiveButton(
         "Yes",
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
             drawView.startNew();
             dialog.dismiss();
           }
         });
     newDialog.setNegativeButton(
         "Cancel",
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
             dialog.cancel();
           }
         });
     newDialog.show();
   } else if (view.getId() == R.id.equals_btn) {
     // save drawing
   }
 }
示例#9
0
    @Override
    protected void onPostExecute(List<Action> actions) {
      if (actions == null) {
        statusLabel.setText("Unable to get actions");
        return;
      }

      // all is ok, replace start pane
      LinearLayout contentPane = (LinearLayout) findViewById(R.id.contentPane);
      contentPane.removeView(startPane);

      LinearLayout buttonsLayout = new LinearLayout(getApplicationContext());
      buttonsLayout.setGravity(Gravity.CENTER);

      TableLayout buttonsTable = new TableLayout(getApplicationContext());
      TableRow currentTableRow = new TableRow(getApplicationContext());

      TableRow.LayoutParams buttonMarginParams =
          new TableRow.LayoutParams(
              TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
      int marginPx =
          (int)
              TypedValue.applyDimension(
                  TypedValue.COMPLEX_UNIT_DIP, 5, getResources().getDisplayMetrics());
      buttonMarginParams.setMargins(marginPx, marginPx, marginPx, marginPx);

      for (final Action action : actions) {
        ImageButton actionButton = new ImageButton(getApplicationContext());
        int drawableId = getResources().getIdentifier(action.icon, "drawable", getPackageName());
        actionButton.setImageDrawable(getResources().getDrawable(drawableId));
        actionButton.setContentDescription(action.description);
        actionButton.setLayoutParams(buttonMarginParams);
        actionButton.setBackgroundResource(R.drawable.button);
        actionButton.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                new PerformActionAsyncTask().execute(action.name);
              }
            });

        currentTableRow.addView(actionButton);
        if (currentTableRow.getChildCount() == 3) {
          buttonsTable.addView(currentTableRow);
          currentTableRow = new TableRow(getApplicationContext());
        }
      }

      if (currentTableRow.getChildCount() > 0) {
        buttonsTable.addView(currentTableRow);
      }

      buttonsLayout.addView(buttonsTable);

      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      contentPane.addView(buttonsLayout, params);

      runStatusUpdateTimer();
    }
示例#10
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    user = (EditText) findViewById(R.id.user);
    pass = (EditText) findViewById(R.id.pass);
    imgBtn = (ImageButton) findViewById(R.id.imgBtn);
    subLayout = (LinearLayout) this.findViewById(R.id.subLayout);
    mContext = this;
    btn = (Button) findViewById(R.id.btn);
    extensionBtn = (Button) findViewById(R.id.extensionBtn);

    // Generate textview dynamically
    TextView tv = new TextView(this);
    tv.setText("这是动态添加的textView");
    subLayout.addView(tv);

    View.OnClickListener imgBtnListener =
        new View.OnClickListener() {
          public void onClick(View view) {
            if (user.getText().toString().equals("LeiBusi")
                && pass.getText().toString().equals("Halo3Q")) {
              user.setVisibility(View.GONE);
              pass.setVisibility(View.GONE);
              imgBtn.setImageResource(R.mipmap.state2);
            } else {
              user.setText("LeiBusi");
              pass.setText("");
              pass.setHint("帐号或密码错误");
              pass.requestFocus();

              Toast toast = Toast.makeText(mContext, "密码错误", Toast.LENGTH_LONG);
              toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
              toast.show();
            }
          }
        };

    View.OnLongClickListener imgBtnLongListener =
        new View.OnLongClickListener() {
          public boolean onLongClick(View view) {
            TextView tv = new TextView(mContext);
            tv.setText("这是动态添加的textView");
            subLayout.addView(tv);
            return true;
          }
        };

    View.OnClickListener btnListener =
        new View.OnClickListener() {
          public void onClick(View view) {
            user.setText("");
            pass.setText("");
            pass.setHint("请输入密码");
            user.setVisibility(View.VISIBLE);
            pass.setVisibility(View.VISIBLE);
            user.requestFocus();
            imgBtn.setImageResource(R.mipmap.state1);

            if (subLayout.getChildCount() > 0) {
              subLayout.removeAllViews();
            }

            TextView tv = new TextView(mContext);
            tv.setText("这是动态添加的textView");
            subLayout.addView(tv);
          }
        };

    View.OnClickListener extensionBtnListener =
        new View.OnClickListener() {
          public void onClick(View view) {
            Intent Extra = new Intent(MainActivity.this, Extra.class);
            startActivity(Extra);
          }
        };

    imgBtn.setOnClickListener(imgBtnListener);
    imgBtn.setOnLongClickListener(imgBtnLongListener);
    btn.setOnClickListener(btnListener);
    extensionBtn.setOnClickListener(extensionBtnListener);
  }