Пример #1
0
  @Override
  protected void onResume() {
    super.onResume();

    final String intentAnswerId = getIntent().getExtras().getString(INTENT_ANSWER_EXTRA);
    IntentAnswer.getIntentAnswer(
        intentAnswerId,
        new GetCallback<IntentAnswer>() {

          @Override
          public void done(IntentAnswer intentAnswer, ParseException error) {
            if (error == null) {
              updateView(intentAnswer);
            } else {
              Log.e(TAG, "Cannot load intent", error);
              // Let's update the data and try again
              fetchIntentAnswer(intentAnswerId);
            }
          }
        });

    registerNotificationReceiver();

    ActionLog.log("resumed intent answer activity", intentAnswerId);
    AppEventsLogger.activateApp(this);
  }
Пример #2
0
  @Override
  protected void onPause() {
    super.onPause();

    // Save read flag
    intentAnswer.saveInBackground();

    if (newMessageListener != null) {
      messagesRef.removeEventListener(newMessageListener);
    }

    if (chatStatusListener != null) {
      friendTypingRef.removeEventListener(chatStatusListener);
    }

    if (onlineStatusListener != null) {
      friendOnlineRef.removeEventListener(onlineStatusListener);
    }

    if (userTypingRef != null) {
      userTypingRef.setValue(false);
    }

    if (receiver != null) {
      unregisterReceiver(receiver);
    }

    ActionLog.log("paused intent answer activity");
    AppEventsLogger.deactivateApp(this);
  }
Пример #3
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, android.content.Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK && requestCode == REQUEST_SELECT_FILE && data != null) {
      ActionLog.log("chose photo from gallery");
      Uri selectedImageUri = data.getData();
      String tempPath = FileTools.getRealPathFromURI(this, selectedImageUri);
      sendImageMessage(tempPath);
    }

    if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
      ActionLog.log("took photo");
      sendImageMessage(mCurrentPhotoPath);
    }
  }
Пример #4
0
 private void sendImageMessage(String tempPath) {
   try {
     messagesFragment.sendImageMessage(tempPath);
   } catch (IOException e) {
     ActionLog.logException("Cannot read image");
     Log.e(TAG, "Cannot read image", e);
     Dialogs.showError(this, getString(R.string.cannot_read_image));
   }
 }
Пример #5
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        // Respond to the action bar's Up/Home button
      case android.R.id.home:
        android.content.Intent upIntent = NavUtils.getParentActivityIntent(this);
        if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
          TaskStackBuilder.create(this).addNextIntentWithParentStack(upIntent).startActivities();
        } else {
          NavUtils.navigateUpTo(this, upIntent);
        }
        return true;
      case R.id.action_from_gallery:
        ActionLog.log("gallery opened");
        openGallery();
        return true;
      case R.id.action_take_photo:
        ActionLog.log("camera opened");
        dispatchTakePictureIntent();
        return true;
    }

    return super.onOptionsItemSelected(item);
  }