Example #1
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public void onFragmentInteraction(final Uri taskUri, final long listId, final View origin) {
    final Intent intent =
        new Intent()
            .setAction(Intent.ACTION_EDIT)
            .setClass(this, ActivityMain_.class)
            .setData(taskUri)
            .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
            .putExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, listId);
    // User clicked a task in the list
    // tablet
    if (fragment2 != null) {
      // Set the intent here also so rotations open the same item
      setIntent(intent);
      getSupportFragmentManager()
          .beginTransaction()
          .setCustomAnimations(R.anim.slide_in_top, R.anim.slide_out_bottom)
          .replace(R.id.fragment2, TaskDetailFragment_.getInstance(taskUri))
          .commitAllowingStateLoss();
      taskHint.setVisibility(View.GONE);
    }
    // phone
    else {

      // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
      // && origin != null) {
      // Log.d("nononsenseapps animation", "Animating");
      // //intent.putExtra(ANIMATEEXIT, true);
      // startActivity(
      // intent,
      // ActivityOptions.makeCustomAnimation(this,
      // R.anim.activity_slide_in_left,
      // R.anim.activity_slide_out_left).toBundle());

      // }
      // else {
      Log.d("nononsenseapps animation", "Not animating");
      startActivity(intent);
      // }
    }
  }
Example #2
0
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
  @Override
  public void addTaskInList(final String text, final long listId) {
    if (listId < 1) {
      // Cant add to invalid lists
      return;
    }
    final Intent intent =
        new Intent()
            .setAction(Intent.ACTION_INSERT)
            .setClass(this, ActivityMain_.class)
            .setData(Task.URI)
            .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
            .putExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, listId);
    if (fragment2 != null) {
      // Set intent to preserve state when rotating
      setIntent(intent);
      // Replace editor fragment
      getSupportFragmentManager()
          .beginTransaction()
          .setCustomAnimations(R.anim.slide_in_top, R.anim.slide_out_bottom)
          .replace(R.id.fragment2, TaskDetailFragment_.getInstance(text, listId))
          .commitAllowingStateLoss();
      taskHint.setVisibility(View.GONE);
    } else {
      // Open an activity

      // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      // Log.d("nononsenseapps animation", "Animating");
      // intent.putExtra(ANIMATEEXIT, true);
      // startActivity(
      // intent,
      // ActivityOptions.makeCustomAnimation(this,
      // R.anim.activity_slide_in_left,
      // R.anim.activity_slide_out_left).toBundle());
      // }
      // else {
      startActivity(intent);
      // }
    }
  }
Example #3
0
  @UiThread(propagation = Propagation.REUSE)
  void loadFragments() {
    final Intent intent = getIntent();

    // Mandatory
    Fragment left = null;
    String leftTag = null;
    // Only if fragment2 is not null
    Fragment right = null;

    if (this.state != null) {
      this.state = null;
      if (showingEditor && fragment2 != null) {
        // Should only be true in portrait
        showingEditor = false;
      }

      // Find fragments
      // This is an instance state variable
      if (showingEditor) {
        // Portrait, with editor, modify action bar
        setHomeAsDrawer(false);
        // Done
        return;
      } else {
        // Find the listpager
        left = getSupportFragmentManager().findFragmentByTag(LISTPAGERTAG);
        listOpener = (ListOpener) left;

        if (left != null && fragment2 == null) {
          // Done
          return;
        } else if (left != null && fragment2 != null) {
          right = getSupportFragmentManager().findFragmentByTag(DETAILTAG);
        }

        if (left != null && right != null) {
          // Done
          return;
        }
      }
    }

    // Load stuff
    final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    if (reverseAnimation) {
      reverseAnimation = false;
      transaction.setCustomAnimations(
          R.anim.slide_in_bottom,
          R.anim.slide_out_top,
          R.anim.slide_in_top,
          R.anim.slide_out_bottom);
    } else {
      transaction.setCustomAnimations(
          R.anim.slide_in_top,
          R.anim.slide_out_bottom,
          R.anim.slide_in_bottom,
          R.anim.slide_out_top);
    }

    /*
     * If it contains a noteId, load an editor. If also tablet, load the
     * lists.
     */
    if (fragment2 != null) {
      if (right == null) {
        if (getNoteId(intent) > 0) {
          right = TaskDetailFragment_.getInstance(getNoteId(intent));
        } else if (isNoteIntent(intent)) {
          right =
              TaskDetailFragment_.getInstance(
                  getNoteShareText(intent),
                  TaskListViewPagerFragment.getAShowList(this, getListId(intent)));
        }
      }
    } else if (isNoteIntent(intent)) {
      showingEditor = true;
      listOpener = null;
      leftTag = DETAILTAG;
      if (getNoteId(intent) > 0) {
        left = TaskDetailFragment_.getInstance(getNoteId(intent));
      } else {
        // Get a share text (null safe)
        // In a list (if specified, or default otherwise)
        left =
            TaskDetailFragment_.getInstance(
                getNoteShareText(intent),
                TaskListViewPagerFragment.getARealList(this, getListId(intent)));
      }
      // f*****g stack
      while (getSupportFragmentManager().popBackStackImmediate()) {
        // Need to pop the entire stack and then load
      }
      if (shouldAddToBackStack) {
        transaction.addToBackStack(null);
      }

      setHomeAsDrawer(false);
    }
    /*
     * Other case, is a list id or a tablet
     */
    if (!isNoteIntent(intent) || fragment2 != null) {
      // If we're no longer in the editor, reset the action bar
      if (fragment2 == null) {
        setHomeAsDrawer(true);
      }
      // TODO
      showingEditor = false;

      left = TaskListViewPagerFragment.getInstance(getListIdToShow(intent));
      leftTag = LISTPAGERTAG;
      listOpener = (ListOpener) left;
    }

    if (fragment2 != null && right != null) {
      transaction.replace(R.id.fragment2, right, DETAILTAG);
      taskHint.setVisibility(View.GONE);
    }
    transaction.replace(R.id.fragment1, left, leftTag);

    // Commit transaction
    // Allow state loss as workaround for bug
    // https://code.google.com/p/android/issues/detail?id=19917
    transaction.commitAllowingStateLoss();
    // Next go, always add
    shouldAddToBackStack = true;
  }