Java Code Examples for android.support.v4.app.Fragment#onActivityResult()

The following examples show how to use android.support.v4.app.Fragment#onActivityResult() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FixedOnActivityResultBugFragment.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Checks to see whether there is any children fragments which has been registered with
 * {@code requestCode} before. If so, let it handle the {@code requestCode}.
 *
 * @param requestCode the code from {@link #onActivityResult(int, int, android.content.Intent)}.
 * @param resultCode  the code from {@link #onActivityResult(int, int, android.content.Intent)}.
 * @param data        the data from {@link #onActivityResult(int, int, android.content.Intent)}.
 * @return {@code true} if the results have been handed over to some child fragment.
 * {@code false} otherwise.
 */
protected boolean checkNestedFragmentsForResult(int requestCode, int resultCode, Intent data) {
    final int id = mRequestCodes.get(requestCode);
    if (id == 0)
        return false;

    mRequestCodes.delete(requestCode);

    List<Fragment> fragments = getChildFragmentManager().getFragments();
    if (fragments == null)
        return false;

    for (Fragment fragment : fragments) {
        if (fragment.hashCode() == id) {
            fragment.onActivityResult(requestCode, resultCode, data);
            return true;
        }
    }

    return false;
}
 
Example 2
Source File: SettingsDialog.java    From AdaptiveTableLayout with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.bPositive:
            sendResult();
            break;
        case R.id.bNegative:
            Fragment fragment = getParentFragment();
            if (fragment != null) {
                fragment.onActivityResult(REQUEST_CODE_SETTINGS, Activity.RESULT_CANCELED, null);
            }
            break;
        default:
            //do nothing
    }
    dismiss();
}
 
Example 3
Source File: MainActivity.java    From BusyBox with Apache License 2.0 6 votes vote down vote up
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (ExternalStorageHelper.getInstance().onActivityResult(requestCode, resultCode, data)) {
    return;
  }
  if (requestCode == ScriptsFragment.REQUEST_CREATE_SCRIPT) {
    Fragment fragment = getCurrentFragment(getSupportFragmentManager(), viewPager);
    if (fragment instanceof ScriptsFragment) {
      // android.app.support.v4.Fragment doesn't have
      // startActivityForResult(Intent intent, int requestCode, Bundle options)
      // so wee need to pass the result on
      fragment.onActivityResult(requestCode, resultCode, data);
      return;
    }
  }
  super.onActivityResult(requestCode, resultCode, data);
}
 
Example 4
Source File: EditItemDialog.java    From AdaptiveTableLayout with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.bPositive:
            sendResult();
            break;
        case R.id.bNegative:
            Fragment fragment = getParentFragment();
            if (fragment != null) {
                fragment.onActivityResult(REQUEST_CODE_EDIT_SONG, Activity.RESULT_CANCELED, null);
            }
            break;
        case R.id.tvDelete:
            delete();
            break;
        case R.id.tvAdd:
            add();
            break;
        default:
            //do nothing
    }

    dismiss();
}
 
Example 5
Source File: FixedOnActivityResultBugFragment.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Checks to see whether there is any children fragments which has been registered with
 * {@code requestCode} before. If so, let it handle the {@code requestCode}.
 *
 * @param requestCode the code from {@link #onActivityResult(int, int, android.content.Intent)}.
 * @param resultCode  the code from {@link #onActivityResult(int, int, android.content.Intent)}.
 * @param data        the data from {@link #onActivityResult(int, int, android.content.Intent)}.
 * @return {@code true} if the results have been handed over to some child fragment.
 * {@code false} otherwise.
 */
protected boolean checkNestedFragmentsForResult(int requestCode, int resultCode, Intent data) {
    final int id = mRequestCodes.get(requestCode);
    if (id == 0)
        return false;

    mRequestCodes.delete(requestCode);

    List<Fragment> fragments = getChildFragmentManager().getFragments();
    if (fragments == null)
        return false;

    for (Fragment fragment : fragments) {
        if (fragment.hashCode() == id) {
            fragment.onActivityResult(requestCode, resultCode, data);
            return true;
        }
    }

    return false;
}
 
Example 6
Source File: DeleteDialog.java    From AdaptiveTableLayout with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.bPositive:
            // positive
            delete();
            break;
        case R.id.bNegative:
            // negative
            Fragment fragment = getParentFragment();
            if (fragment != null) {
                fragment.onActivityResult(REQUEST_CODE_DELETE_ROW_CONFIRMED, Activity.RESULT_CANCELED, null);
            }
            break;
        default:
            //do nothing
    }

    dismiss();
}
 
Example 7
Source File: AddColumnDialog.java    From AdaptiveTableLayout with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.bColumnRight:
            sendResult(mColumn, false);
            break;
        case R.id.bColumnLeft:
            sendResult(mColumn, true);
            break;
        case R.id.bNegative:
            // negative
            Fragment fragment = getParentFragment();
            if (fragment != null) {
                fragment.onActivityResult(REQUEST_CODE_ADD_COLUMN_CONFIRMED, Activity.RESULT_CANCELED, null);
            }
            break;
        default:
            //do nothing
    }
    dismiss();
}
 
Example 8
Source File: ApplicationPreferencesActivity.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
  super.onActivityResult(requestCode, resultCode, data);
  Fragment fragment = getSupportFragmentManager().findFragmentById(android.R.id.content);
  fragment.onActivityResult(requestCode, resultCode, data);
}
 
Example 9
Source File: MainActivity.java    From alltv with MIT License 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    for (Fragment fragment : getSupportFragmentManager().getFragments()) {
        fragment.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 10
Source File: CategorySelectionActivity.java    From CoolSignIn with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.category_container);
    if (fragment != null) {
        fragment.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 11
Source File: CommentPage.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 423 && resultCode == Activity.RESULT_OK) {
        doResult(data);
    } else if (requestCode == 3333) {
        for (Fragment fragment : getFragmentManager().getFragments()) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    }

}
 
Example 12
Source File: AddColumnDialog.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
private void sendResult(int column, boolean beforeORAfter) {
    Fragment fragment = getParentFragment();
    if (fragment != null) {
        Intent intent = new Intent();
        intent.putExtra(EXTRA_COLUMN_NUMBER, column);
        intent.putExtra(EXTRA_BEFORE_OR_AFTER, beforeORAfter);
        fragment.onActivityResult(REQUEST_CODE_ADD_COLUMN_CONFIRMED, Activity.RESULT_OK, intent);
    }
}
 
Example 13
Source File: AddRowDialog.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
private void sendResult(int row, boolean beforeORAfter) {
    Fragment fragment = getParentFragment();
    if (fragment != null) {
        Intent intent = new Intent();
        intent.putExtra(EXTRA_ROW_NUMBER, row);
        intent.putExtra(EXTRA_BEFORE_OR_AFTER, beforeORAfter);
        fragment.onActivityResult(REQUEST_CODE_ADD_ROW_CONFIRMED, Activity.RESULT_OK, intent);
    }
}
 
Example 14
Source File: MainActivity.java    From Loop with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.content_fl);
    if (fragment != null) {
        fragment.onActivityResult(requestCode, resultCode, data);
    }
}
 
Example 15
Source File: EditItemDialog.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
private void sendResult(String extra, int data, int requestCode) {
    Fragment fragment = getParentFragment();
    if (fragment != null) {
        Intent intent = new Intent();
        intent.putExtra(extra, data);
        fragment.onActivityResult(requestCode, Activity.RESULT_OK, intent);
    }
}
 
Example 16
Source File: EditItemDialog.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
private void sendResult() {
    Fragment fragment = getParentFragment();
    if (fragment != null) {
        Intent intent = new Intent();
        String str = mEtValue.getText().toString().trim();
        intent.putExtra(EXTRA_VALUE, str.isEmpty() ? " " : str);
        intent.putExtra(EXTRA_COLUMN_NUMBER, mColumn);
        intent.putExtra(EXTRA_ROW_NUMBER, mRow);
        fragment.onActivityResult(REQUEST_CODE_EDIT_SONG, Activity.RESULT_OK, intent);
    }
}
 
Example 17
Source File: SettingsDialog.java    From AdaptiveTableLayout with MIT License 5 votes vote down vote up
private void sendResult() {
    Fragment fragment = getParentFragment();
    if (fragment != null) {
        Intent intent = new Intent();
        intent.putExtra(EXTRA_VALUE_SOLID_HEADER, mSolidRowHeader);
        intent.putExtra(EXTRA_VALUE_HEADER_FIXED, mIsHeaderFixed);
        intent.putExtra(EXTRA_VALUE_RTL_DIRECTION, mIsRtlDirection);
        intent.putExtra(EXTRA_VALUE_DRAG_AND_DROP_ENABLED, mIsDragAndDropEnabled);
        fragment.onActivityResult(REQUEST_CODE_SETTINGS, Activity.RESULT_OK, intent);
    }
}
 
Example 18
Source File: MainActivity.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Fragment fragment = homeFragment;
    fragment.onActivityResult(requestCode, resultCode, data);
    hideProgress();
    if (requestCode == Constants.REQUEST_QQ_SHARE || requestCode == Constants.REQUEST_QZONE_SHARE || requestCode == Constants.REQUEST_OLD_SHARE) {
        Tencent.handleResultData(data, new BaseUIListener(MainActivity.this, true));
    }
}
 
Example 19
Source File: BaseFragment.java    From COCOFramework with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    List<Fragment> fragments = getChildFragmentManager().getFragments();
    if (fragments != null) {
        for (Fragment fragment : fragments) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    }
}
 
Example 20
Source File: RecipientPreferenceActivity.java    From Silence with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.preference_fragment);
  fragment.onActivityResult(requestCode, resultCode, data);
}