Beispiel #1
0
    @Override
    protected void onPostExecute(String s) {
      pd.dismiss();
      try {
        if (s.equalsIgnoreCase("y")) {
          MyApp.tracker().setScreenName("Feedback Screen");
          MyApp.tracker()
              .send(
                  new HitBuilders.EventBuilder("Button", "Click")
                      .setCategory("UI")
                      .setAction("Click")
                      .setLabel("Submit")
                      .build());

          finish();
          Toast.makeText(
                  getApplicationContext(),
                  "Your message has been sent to SYT customer support team.",
                  Toast.LENGTH_LONG)
              .show();
        } else {
          finish();
        }
      } catch (Exception e) {
        e.printStackTrace();
      } finally {

      }
    }
 @Before
 public void initialize() {
   service = mock(MyService.class);
   otherService = mock(OtherService.class);
   app = new MyApp();
   app.service = service;
   app.otherService = otherService;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    MyApp appState = (MyApp) getApplicationContext();
    appState.addActivity(this);
    setContentView(R.layout.choose_unit_activity);
    // =============================
    setTitle(Constant.FILE_NAME);
  }
 private void restartService(Context context, SharedPreferences prefs) {
   FTD.Settings settings = new FTD.Settings(prefs);
   MyApp.updateService(context, false, false, false, false);
   MyApp.updateService(
       context,
       settings.pressure.enabled,
       settings.size.enabled,
       settings.floatingActionEnabled,
       settings.showNotification);
 }
 public void saveNumberFamiliar(String number) {
   Context context = MyApp.getContext();
   SharedPreferences settings = context.getSharedPreferences(FAA_PREFS, MODE_PRIVATE);
   SharedPreferences.Editor editor = settings.edit();
   editor.putString("numberPhone", number);
   editor.commit();
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.other);
   myApp = (MyApp) getApplication();
   TextView textView = (TextView) findViewById(R.id.textView);
   textView.setText(myApp.getName());
 }
 @Test
 public void captureArguments() {
   app.operationThree();
   ArgumentCaptor capturedArgs = ArgumentCaptor.forClass(String.class);
   verify(service).operationOne();
   verify(otherService).operationThree(capturedArgs.capture().toString());
   assertTrue(capturedArgs.getAllValues().contains("success"));
   verifyNoMoreInteractions(service, otherService);
 }
 @Test
 public void verifyMultipleCalls() {
   String args = "one";
   when(otherService.operationTwo(args)).thenReturn(args);
   app.operationTwo(args);
   verify(otherService).operationTwo(args);
   verify(otherService).operationThree(args);
   verifyNoMoreInteractions(otherService);
   verifyZeroInteractions(service);
 }
Beispiel #9
0
  @Override
  public void onViewCreated(View arg0, Bundle arg1) {
    super.onViewCreated(arg0, arg1);
    DevOpenHelper helper = new DaoMaster.DevOpenHelper(MyApp.getInstance(), "myCattle", null);
    db = helper.getWritableDatabase();
    daoMaster = new DaoMaster(db);
    daoSession = daoMaster.newSession();
    vaccineDao = daoSession.getVaccineDao();

    String nameColumn = VaccineDao.Properties.Name.columnName;
    cursor =
        db.query(
            vaccineDao.getTablename(), vaccineDao.getAllColumns(), null, null, null, null, null);
    String[] from = {nameColumn, VaccineDao.Properties.Name.columnName};
    int[] to = {android.R.id.text1, android.R.id.text2};
    @SuppressWarnings("deprecation")
    SimpleCursorAdapter adapter =
        new SimpleCursorAdapter(
            MyApp.getInstance(), android.R.layout.simple_list_item_2, cursor, from, to);
    setListAdapter(adapter);
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   MyApp.getInstance().addActivity(this);
   setContentView(R.layout.mulu);
   heballtCollectConnect = new HeballtConnect();
   Intent intent1 = getIntent();
   // 用intent1.getStringExtra()来得到上一个ACTIVITY发过来的字符串。
   one = intent1.getStringExtra("FID");
   listView = (ListView) findViewById(R.id.listView3);
   button = (Button) findViewById(R.id.id_left_mulu);
   iconfont = Typeface.createFromAsset(getAssets(), "icomoon.ttf");
   button.setTypeface(iconfont);
   url = getResources().getString(R.string.ip) + "/chapter.php?fid=";
   url += one;
   new Thread(update_thread).start();
 }
  @Override
  protected void onResume() {
    super.onResume();

    if (prefs.getBoolean("firstrun", true)) {
      Intent intent = new Intent(Intent.ACTION_VIEW);
      ;
      intent.setClassName(
          "teamproject.glasgow.reminders_app", "teamproject.glasgow.reminders_app.ExperimentSetup");
      startActivity(intent);
      prefs.edit().putBoolean("firstrun", false).commit();
    }

    if (!MyApp.trialStillRunning()) {
      Intent intent = new Intent(Intent.ACTION_VIEW);
      ;
      intent.setClassName(
          "teamproject.glasgow.reminders_app",
          "teamproject.glasgow.reminders_app.ExperimentFinished");
      startActivity(intent);
    }
  }
Beispiel #12
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   switch (requestCode) {
     case REQUEST_ACTION:
       if (resultCode == RESULT_OK) {
         ActionInfo.Record record =
             (ActionInfo.Record)
                 data.getSerializableExtra(ActionPickerActivity.EXTRA_ACTION_RECORD);
         MyApp.logD("picked intent: " + record.intentUri);
         // save
         Preference pref = findPreference(mPrefKey);
         pref.getSharedPreferences()
             .edit()
             .putString(mPrefKey, record.toStringForPreference())
             .apply();
         updateActionSummary(pref, record);
       }
       break;
     default:
       super.onActivityResult(requestCode, resultCode, data);
   }
 }
public class BookSelectCancelActivity extends ActionBarActivity implements View.OnClickListener {

  MyApp database = MyApp.getInstance();
  LibrarySystem otterLibrary = database.getDatabase();

  Bundle received;
  Customer myCustomer;
  Book myBook;
  private SimpleDateFormat dateFormat;

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

    Spinner bookSpinner = (Spinner) findViewById(R.id.bookSpinner);
    View select = findViewById(R.id.confirm);
    select.setOnClickListener(this);

    received = getIntent().getExtras();
    myCustomer = received.getParcelable("customer");
    ArrayList<Book> booksForSpinner = new ArrayList<>();

    for (Reservation temp : otterLibrary.reservations) {
      if (myCustomer.equals(temp.getReservedBy())) {
        booksForSpinner.add(temp.getReservedBook());
      }
    }

    List<String> titleList = new ArrayList<String>();
    for (int i = 0; i < booksForSpinner.size(); i++) {
      titleList.add(booksForSpinner.get(i).getTitle());
    }

    ArrayList<String> infoList = new ArrayList<String>();
    for (Book temp : booksForSpinner) {
      infoList.add("Author: " + temp.getAuthor());
      infoList.add("ISBN: " + temp.getIsbn());
      infoList.add("Hourly Fee: " + temp.getFormattedFee());
    }

    ArrayAdapter<String> dataAdapter =
        new ArrayAdapter<String>(this, R.layout.spinner_item, titleList);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    bookSpinner.setAdapter(dataAdapter);
    bookSpinner.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            TextView author = (TextView) findViewById(R.id.textView5);
            TextView isbn = (TextView) findViewById(R.id.textView7);
            TextView fee = (TextView) findViewById(R.id.textView8);

            String title = parent.getItemAtPosition(position).toString();
            System.out.println(title);

            for (Book temp : otterLibrary.books) {
              if (temp.getTitle().equals(title)) {
                author.setText("Author: " + temp.getAuthor());
                isbn.setText("ISBN: " + temp.getIsbn());
                fee.setText("Hourly Fee: " + temp.getFormattedFee());
                myBook = temp;
              }
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }

  public void onClick(View v) {
    if (v.getId() == R.id.confirm) {
      // add code to remove the reservation

      dateFormat = new SimpleDateFormat("MM/dd/yyyy h:mm a", Locale.US);

      DateFormat transDateFormat = new SimpleDateFormat("MM/dd/yyyy");
      DateFormat transTimeFormat = new SimpleDateFormat("h:mm a");

      Long checkDate = null;
      Long returnDate = null;
      Date date = new Date();

      String resNum = "";

      for (Reservation temp : otterLibrary.reservations) {
        if (myBook.equals(temp.getReservedBook())) {
          System.out.println("they are equal");
          otterLibrary.availableBooks.add(
              myBook); // this should let the book be available for a hold again
          checkDate = temp.getCheckoutDate();
          returnDate = temp.getReturnDate();
          resNum = Integer.toString(temp.getReservationNumber());
        }
      }

      otterLibrary.addToLogs("----------------", "---------------");
      otterLibrary.addToLogs("Transaction Type: ", "Cancel Hold");
      otterLibrary.addToLogs("Customer's Username: "******"Book Title: ", myBook.getTitle());
      otterLibrary.addToLogs("Pickup Date: ", dateFormat.format(checkDate));
      otterLibrary.addToLogs("Return Date: ", dateFormat.format(returnDate));
      otterLibrary.addToLogs("Reservation Number: ", resNum);
      otterLibrary.addToLogs(
          "Transaction Date: ", transDateFormat.format(date)); // double check this
      otterLibrary.addToLogs("Transaction Time: ", transTimeFormat.format(date));
      otterLibrary.addToLogs("----------------", "---------------");

      Intent i = new Intent(this, MainActivity.class);
      startActivity(i);
    }
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_book_select_cancel, menu);
    return true;
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
}
Beispiel #14
0
 @Provides
 @Singleton
 LocationManager provideLocationManager() {
   return (LocationManager) app.getSystemService(Context.LOCATION_SERVICE);
 }
 public String getNumberFamiliar() {
   Context context = MyApp.getContext();
   SharedPreferences settings = context.getSharedPreferences(FAA_PREFS, MODE_PRIVATE);
   return (settings.getString("numberPhone", ""));
 }
 @Test(expected = RuntimeException.class)
 public void verifyException() {
   doThrow(new RuntimeException()).when(service).operationOne();
   app.operationOne();
 }
 @Test
 public void verifySimpleCall() {
   app.operationOne();
   verify(service).operationOne();
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    MyApp.initOnBroadCastReceiver(this);
    super.onCreate(savedInstanceState);
    // prefs = getSharedPreferences("teamproject.glasgow.reminders_app", MODE_PRIVATE);
    prefs = MyApp.getPrefs();

    setContentView(R.layout.activity_reminders);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    //        cloudMem = new ParseStorageAdapter(this);
    //        cloudMem.testAddNewTaskToDB();
    //        cloudMem.getRemindersFromDB();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mActivityTitle = getTitle().toString();
    mDrawerList = (ListView) findViewById(R.id.navList);

    addDrawerItems();
    setupDrawer();

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    if (prefs.getBoolean("firstrun", true)) {
      reminders = HelperFunctions.generateReminderInitData();
      PersistencyManager.saveReminders(reminders, true);
    } else {
      // reminders = PersistencyManager.getReminders();
      reminders = MyApp.getReminders();
    }

    // reminders = cloudMem.getRemindersFromDB();
    //        cloudMem.searchReminder("a");

    expandableListView = (ExpandableListView) findViewById(R.id.ExpList);

    // Display indicator on the right
    Display newDisplay = getWindowManager().getDefaultDisplay();
    int width = newDisplay.getWidth();
    expandableListView.setIndicatorBounds(width - 100, width);

    ExpAdapter = new ExpandListAdapter(Reminders.this, reminders);
    expandableListView.setAdapter(ExpAdapter);

    // expand all items
    for (int i = 0; i < ExpAdapter.getGroupCount(); i++) {
      expandableListView.expandGroup(i);
    }

    expandableListView.setOnChildClickListener(
        new ExpandableListView.OnChildClickListener() {

          @Override
          public boolean onChildClick(
              ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
            Occurrence occurrence = (Occurrence) ExpAdapter.getChild(groupPosition, childPosition);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(
                "teamproject.glasgow.reminders_app",
                "teamproject.glasgow.reminders_app.ModifyReminder");
            intent.putExtra("display_type", "modify_reminder");
            Reminder reminder = occurrence.getReminder();
            intent.putExtra("reminder", reminder);
            intent.putExtra("index", reminders.getReminders().indexOf(reminder));
            // AlarmSetter.cancelRepeatingAlarmForReminder(reminder, null);
            startActivityForResult(intent, 2);
            return true;
          }
        });

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {

            // Intent intent = new Intent(view.getContext(), ModifyReminder.class);
            // startActivity(intent);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setClassName(
                "teamproject.glasgow.reminders_app",
                "teamproject.glasgow.reminders_app.ModifyReminder");
            intent.putExtra("display_type", "add_reminder");
            startActivityForResult(intent, 1);
          }
        });

    // setButtonColor
    Drawable myFabSrc =
        ResourcesCompat.getDrawable(getResources(), android.R.drawable.ic_input_add, getTheme());
    Drawable white = myFabSrc.getConstantState().newDrawable();
    white.mutate().setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    fab.setImageDrawable(white);

    _reminders = this;
    MyApp.setReminders(reminders);
    UserID = MyApp.getUserID();
    Intent i = this.getIntent();
    if (i.getBooleanExtra("restart", false)) {
      moveTaskToBack(true);
    }
  }
  @Override
  public void run() {

    /*
     *  tell my intent to the center server: join monitoring
     */
    byte[] myIntent = new byte[] {'J', 'O', 'I', 'N'};
    try {
      mOutputStream.write(myIntent);
    } catch (IOException e1) {
      Log.d("Conn", "IOException in RequestMonitoring");
      e1.printStackTrace();
    }

    int highbyte = 0;
    int lowbyte = 0;

    try {
      highbyte = mInputStream.read();
      lowbyte = mInputStream.read();
    } catch (IOException e) {
      Log.d("Conn", "IOException in RequestMonitoring");
      e.printStackTrace();
    }

    showResponse("mTextView2", "getting Capture end information");
    Log.d("Conn", " " + highbyte + " " + lowbyte);

    int captureEndInfolen = (highbyte << 8) + lowbyte;

    byte[] captureEndInfo = new byte[captureEndInfolen];

    try {
      mInputStream.read(captureEndInfo, 0, captureEndInfolen);
    } catch (IOException e) {
      Log.d("Conn", "IOException in RequestMonitoring");
      e.printStackTrace();
    }

    /*
     * process the available capture end name and add them to list
     */
    ByteArrayInputStream inputStream = new ByteArrayInputStream(captureEndInfo);
    while (true) {
      int captureEndNameLen = inputStream.read();
      if (captureEndNameLen < 0) break;

      byte[] captureEndName = new byte[captureEndNameLen];
      inputStream.read(captureEndName, 0, captureEndNameLen);
      String strCapName = null;
      try {
        strCapName = new String(captureEndName, "ISO-8859-1");
      } catch (UnsupportedEncodingException e) {
        Log.d("Debug", "UnsupportedEncodingException in RequestMonitoring");
        e.printStackTrace();
      }
      if (strCapName.length() > 0) mAvailableCaptureEndList.add(strCapName);
    }

    Log.d("Debug", "available cap num: " + mAvailableCaptureEndList.size());

    showResponse("Button", "update");

    getMonitorEndChoice();

    if (null == mMonitorEndChoice) {
      try {
        mSocket.close();
      } catch (IOException e) {
        Log.d("Debug", "IOException in RequestMonitoring");
        e.printStackTrace();
      }
      return;
    }

    /*
     * send the choice of monitor end
     */
    try {
      byte[] monitorEndChoice = mMonitorEndChoice.getBytes("ISO-8859-1");
      mOutputStream.write(monitorEndChoice.length);
      mOutputStream.write(monitorEndChoice);
    } catch (IOException e) {
      Log.d("Conn", "IOException in RequestMonitoring");
      e.printStackTrace();
    }

    //		/*
    //		 * get the multicast address
    //		 */
    //		String multicastAddress = null;
    //		byte[] multicastAddr = null;
    //		try {
    //			int multicastAddrLen = mInputStream.read();
    //			multicastAddr = new byte[multicastAddrLen];
    //			mInputStream.read(multicastAddr, 0, multicastAddrLen);
    //
    //		} catch (IOException e) {
    //			Log.d("Conn", "IOException in ConnectCenterServer");
    //			e.printStackTrace();
    //		}
    //
    //		try {
    //			multicastAddress = new String(multicastAddr, "ISO-8859-1");
    //		} catch (UnsupportedEncodingException e) {
    //			Log.d("Conn", "UnsupportedEncodingException in ConnectCenterServer");
    //			e.printStackTrace();
    //		}

    MyApp mMyApp = (MyApp) mActivity.getApplicationContext();
    mMyApp.setSocket(mSocket);
    //		mIntent.putExtra("multicastAddress", multicastAddress);

    mActivity.startActivityForResult(mIntent, MainAct.REQ_CODE_FINISHED);
  }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.place_detail);

    MyApp app = (MyApp) getApplicationContext();
    final Place place = app.getPlaceByUuid(getIntent().getExtras().getString("uuid"));

    if (place == null) {
      Log.i("info", "Couldnt find place!");
      return;
    }

    TextView textfield = (TextView) findViewById(R.id.textName);
    textfield.setText(place.getName());

    textfield = (TextView) findViewById(R.id.textAddress);
    textfield.setText(place.getAddress());

    textfield = (TextView) findViewById(R.id.textCity);
    textfield.setText("Locality: " + place.getLocality());

    textfield = (TextView) findViewById(R.id.textCountry);
    textfield.setText("Country: " + place.getCountry());

    textfield = (TextView) findViewById(R.id.textNotes);
    textfield.setText(place.getNotes());

    if (place.hasGeometry()) {
      String mapUrl =
          "http://api.tiles.mapbox.com/v3/examples.map-vyofok3q/pin-m-star+88c("
              + Double.toString(place.getLongitude())
              + ","
              + Double.toString(place.getLatitude())
              + ")/"
              + Double.toString(place.getLongitude())
              + ","
              + Double.toString(place.getLatitude())
              + ",15/400x300.png";

      Log.i("info", mapUrl);

      ImageButton mButton = (ImageButton) findViewById(R.id.imageButtonMap);
      mButton.setTag(mapUrl);

      new DownloadImagesTask().execute(mButton);

      // Open the google maps app onclick
      mButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Log.i("info", "Clicked place " + place.getName());

              Uri uri =
                  Uri.parse(
                      "geo:0,0?q="
                          + Double.toString(place.getLatitude())
                          + ","
                          + Double.toString(place.getLongitude())
                          + "("
                          + place.getName()
                          + ")");
              Intent intent = new Intent(Intent.ACTION_VIEW, uri);
              startActivity(intent);
            }
          });
    } else {
      Toast.makeText(getBaseContext(), "This place has no map location", Toast.LENGTH_SHORT).show();
    }

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

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), PlaceEditActivity.class);
            i.putExtra("uuid", place.getUuid());
            startActivity(i);
          }
        });
  }
Beispiel #21
0
 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
   AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
   super.onCreateContextMenu(menu, v, menuInfo);
   menu.add(0, 0, 0, global.getString(R.string.delete));
 }