public static void showReaderSubsForResult(Activity activity) {
   Intent intent = new Intent(activity, ReaderSubsActivity.class);
   ActivityOptionsCompat options =
       ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.reader_flyin, 0);
   ActivityCompat.startActivityForResult(
       activity, intent, Constants.INTENT_READER_SUBS, options.toBundle());
 }
 @Override
 public void startForResult(int requestCode) {
   if (fragmentSupport_ != null) {
     fragmentSupport_.startActivityForResult(intent, requestCode);
   } else {
     if (fragment_ != null) {
       if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
         fragment_.startActivityForResult(intent, requestCode, lastOptions);
       } else {
         fragment_.startActivityForResult(intent, requestCode);
       }
     } else {
       if (context instanceof Activity) {
         Activity activity = ((Activity) context);
         ActivityCompat.startActivityForResult(activity, intent, requestCode, lastOptions);
       } else {
         if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
           context.startActivity(intent, lastOptions);
         } else {
           context.startActivity(intent);
         }
       }
     }
   }
 }
 public static void launch(Activity activity, ImageView imageView, Book book, int fromPosition) {
   ActivityOptionsCompat options =
       ActivityOptionsCompat.makeSceneTransitionAnimation(
           activity, imageView, TRANSITION_NAME_IMAGE);
   Intent intent = new Intent(activity, BookDetailsActivity.class);
   intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
   intent.putExtra(EXTRA_BOOK_DATA, book.toJSONString());
   intent.putExtra(EXTRA_POSITION, fromPosition);
   ActivityCompat.startActivityForResult(activity, intent, REQUEST_MAIN, options.toBundle());
 }
Ejemplo n.º 4
0
  private boolean menuClick(View v, boolean longClick) {
    boolean goToTOC = longClick;
    longClick = false;
    MenuButton mb = (MenuButton) v;
    MenuState newMenuState = menuState.goForward(mb.getNode(), mb.getSectionNode());
    Intent intent;
    if (mb.isBook()) {
      Book book = null;
      try {
        if (!Settings.getUseAPI()
            && !Database.hasOfflineDB()) { // There's no DB //TODO make it work with API
          Settings.setUseAPI(true);
        }
        book = new Book(newMenuState.getCurrNode().getTitle(Util.Lang.EN));
        if (goToTOC) {
          intent = TOCActivity.getStartTOCActivityIntent(context, book, null);
          /// intent = new Intent(context, TOCActivity.class);
          // intent.putExtra("currBook", book);
          // intent.putExtra("lang", newMenuState.getLang());
          context.startActivity(intent);
          return true;
        } else {
          SuperTextActivity.startNewTextActivityIntent(context, book, longClick);
        }
      } catch (Book.BookNotFoundException e) {
        Toast.makeText(context, MyApp.getRString(R.string.sorry_book_not_found), Toast.LENGTH_SHORT)
            .show();
      }

    } else {
      intent = new Intent(context, MenuActivity.class);
      Bundle options = null;
      if (longClick) {
        intent = MyApp.startNewTab(intent);
        options =
            ActivityOptionsCompat.makeCustomAnimation(
                    context, R.animator.activity_zoom_in, R.animator.activity_zoom_out)
                .toBundle();
      }
      intent.putExtra("menuState", newMenuState);
      intent.putExtra("hasSectionBack", mb.getSectionNode() != null);
      intent.putExtra("hasTabBack", hasTabs);

      if (longClick) {
        ActivityCompat.startActivityForResult((Activity) context, intent, 0, options);
      } else {
        ((Activity) context).startActivityForResult(intent, 0);
      }
    }

    return false;
  }
  @OnClick(R.id.original_text_input)
  protected void openEditTextWithAnimation() {
    Intent intent = new Intent(getApplicationContext(), ActivityEditText.class);
    intent.putExtra(ActivityEditText.ORIGINAL_TEXT_EXTRA, mOriginalTextInput.getText().toString());

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
      ActivityOptionsCompat activityOptions =
          ActivityOptionsCompat.makeSceneTransitionAnimation(
              ActivityTranslator.this,
              mLanguageInputContainer,
              mLanguageInputContainer.getTransitionName());

      ActivityCompat.startActivityForResult(
          this, intent, REQUEST_CODE_EDIT_TEXT_ACTIVITY, activityOptions.toBundle());
    } else {
      startActivityForResult(intent, REQUEST_CODE_EDIT_TEXT_ACTIVITY);
    }
  }
  public static void showReaderReblogForResult(Activity activity, ReaderPost post, View source) {
    if (activity == null || post == null) {
      return;
    }

    Intent intent = new Intent(activity, ReaderReblogActivity.class);
    intent.putExtra(ReaderActivity.ARG_BLOG_ID, post.blogId);
    intent.putExtra(ReaderActivity.ARG_POST_ID, post.postId);

    ActivityOptionsCompat options;
    if (source != null) {
      int startX = source.getLeft();
      int startY = source.getTop();
      options = ActivityOptionsCompat.makeScaleUpAnimation(source, startX, startY, 0, 0);
    } else {
      options = ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.reader_flyin, 0);
    }
    ActivityCompat.startActivityForResult(
        activity, intent, Constants.INTENT_READER_REBLOG, options.toBundle());
  }
  void openViewer(View view, int index) {
    ImageView iv = (ImageView) view.findViewById(R.id.image);

    final Intent intent = new Intent(getActivity(), ViewerActivity.class);
    Bundle extras = new Bundle();
    extras.putSerializable("wallpapers", mWallpapers);
    extras.putInt(STATE_CURRENT_POSITION, index);
    intent.putExtras(extras);

    final String transName = "view_" + index;
    ViewCompat.setTransitionName(iv, transName);
    final ActivityOptionsCompat options =
        ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(), iv, transName);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      // Somehow this works (setting status bar color in both MainActivity and here)
      // to avoid image glitching through on when ViewActivity is first created.
      getActivity()
          .getWindow()
          .setStatusBarColor(DialogUtils.resolveColor(getActivity(), R.attr.colorPrimaryDark));
      View statusBar =
          getActivity().getWindow().getDecorView().findViewById(android.R.id.statusBarBackground);
      if (statusBar != null) {
        statusBar.post(
            new Runnable() {
              @Override
              public void run() {
                ActivityCompat.startActivityForResult(
                    getActivity(), intent, RQ_VIEWWALLPAPER, options.toBundle());
              }
            });
        return;
      }
    }

    ActivityCompat.startActivityForResult(
        getActivity(), intent, RQ_VIEWWALLPAPER, options.toBundle());
  }
Ejemplo n.º 8
0
 // start the contact launcher
 public void doLaunchContactPicker(View view) {
   Intent contactPickerIntent =
       new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
   startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
 }