Example usage for android.support.v4.app NavUtils navigateUpFromSameTask

List of usage examples for android.support.v4.app NavUtils navigateUpFromSameTask

Introduction

In this page you can find the example usage for android.support.v4.app NavUtils navigateUpFromSameTask.

Prototype

public static void navigateUpFromSameTask(Activity sourceActivity) 

Source Link

Document

Convenience method that is equivalent to calling #navigateUpTo(Activity,Intent) navigateUpTo (sourceActivity, #getParentActivityIntent(Activity) getParentActivityIntent (sourceActivity)).

Usage

From source file:hu.naturlecso.naturshutd.EditHostFragment.java

private void deleteHost() {
    if (mHost != null)
        callbacks.onShowAlertDialog(new AlertDialog.Builder(getActivity())
                .setTitle(R.string.dialog_delete_title).setMessage(R.string.dialog_delete_message)
                .setNegativeButton(android.R.string.cancel, null)
                .setPositiveButton(android.R.string.ok, (dialog, which) -> {
                    Delete.from(Host.class).where(Host._ID + "=?", mHost.id).execute();
                    NavUtils.navigateUpFromSameTask(getActivity());
                }).create());//  w ww.  ja va  2  s . c  o  m
    else
        Toast.makeText(getActivity(), getActivity().getString(R.string.edit_host_nothing), Toast.LENGTH_LONG)
                .show();
}

From source file:com.art2cat.dev.moonlightnote.controller.settings.SettingsActivity.java

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        if (!super.onMenuItemSelected(featureId, item)) {
            NavUtils.navigateUpFromSameTask(this);
        }/*  ww  w. j  av a2 s .c om*/
        if (super.onMenuItemSelected(featureId, item) && isXLargeTablet(this)) {
            startActivity(new Intent(SettingsActivity.this, MoonlightActivity.class));
            this.finish();
        }
        return true;
    }
    return super.onMenuItemSelected(featureId, item);
}

From source file:com.xabber.android.ui.ContactViewer.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
        // View information about contact from system contact list
        Uri data = getIntent().getData();
        if (data != null && "content".equals(data.getScheme())) {
            List<String> segments = data.getPathSegments();
            if (segments.size() == 2 && "data".equals(segments.get(0))) {
                Long id;//from w  w w .  j  a v  a2  s.  co  m
                try {
                    id = Long.valueOf(segments.get(1));
                } catch (NumberFormatException e) {
                    id = null;
                }
                if (id != null)
                    // FIXME: Will be empty while application is loading
                    for (RosterContact rosterContact : RosterManager.getInstance().getContacts())
                        if (id.equals(rosterContact.getViewId())) {
                            account = rosterContact.getAccount();
                            bareAddress = rosterContact.getUser();
                            break;
                        }
            }
        }
    } else {
        account = getAccount(getIntent());
        bareAddress = Jid.getBareAddress(getUser(getIntent()));
    }

    if (bareAddress != null && bareAddress.equalsIgnoreCase(GroupManager.IS_ACCOUNT)) {
        bareAddress = Jid.getBareAddress(AccountManager.getInstance().getAccount(account).getRealJid());
    }

    if (account == null || bareAddress == null) {
        Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
        finish();
        return;
    }

    if (savedInstanceState == null) {
        getFragmentManager().beginTransaction()
                .add(R.id.scrollable_container, ContactVcardViewerFragment.newInstance(account, bareAddress))
                .commit();
    }

    contactTitleExpandableToolbarInflater = new ContactTitleExpandableToolbarInflater(this);
    AbstractContact bestContact = RosterManager.getInstance().getBestContact(account, bareAddress);
    contactTitleExpandableToolbarInflater.onCreate(bestContact);

    View contactTitleView = findViewById(R.id.expandable_contact_title);
    contactTitleView.findViewById(R.id.status_icon).setVisibility(View.GONE);
    contactTitleView.findViewById(R.id.status_text).setVisibility(View.GONE);
    contactNameView = (TextView) contactTitleView.findViewById(R.id.name);

    Toolbar toolbar = contactTitleExpandableToolbarInflater.getToolbar();
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            NavUtils.navigateUpFromSameTask(ContactViewer.this);
        }
    });
}

From source file:org.keionline.keionline.ArticleView.java

@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 == android.R.id.home) {
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }//from   w  w  w  .java2  s . c o m
    if (id == R.id.action_share) {
        // share intent
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, title);
        sendIntent.putExtra(Intent.EXTRA_TEXT, url);
        sendIntent.setType("text/plain");
        startActivity(sendIntent);
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.mZone.epro.EproBaseActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    AppLog.in(LOG_TAG, "onOptionsItemSelected() item=%s", item);
    boolean consumed = false;

    switch (item.getItemId()) {
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        consumed = true;/*from  w  ww. j  av a  2s .com*/
        break;
    default:
        // ?
        consumed = super.onOptionsItemSelected(item);
        break;
    }

    AppLog.out(LOG_TAG, "onOptionsItemSelected() consumed=%s", consumed);
    return consumed;
}

From source file:com.weebly.opus1269.copyeverywhere.ui.devices.DevicesActivity.java

@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.
    boolean processed = true;

    final int id = item.getItemId();
    switch (id) {
    case R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        break;//w  ww .  jav  a  2s  . c om
    case R.id.action_refresh:
        doRefresh();
        break;
    case R.id.action_delete:
        //                showDeleteDialog();
        break;
    default:
        processed = false;
        break;
    }

    return processed || super.onOptionsItemSelected(item);
}

From source file:net.xisberto.phonetodesktop.ui.LinkListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        NavUtils.navigateUpFromSameTask(this);
        return true;
    case R.id.item_refresh:
        if (swipeRefreshLayout.isRefreshing()) {
            return true;
        }/*from w w w. j  av a  2  s . co m*/
        refreshTasks();
        return true;
    }
    return false;
}

From source file:org.ciasaboark.tacere.activity.SettingsActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_settings_restore:
        //restore settings to default values then navigate to the main activity
        restoreDefaults();// w  w w .  j av a2  s .c  o  m
        //navigate back to the main screen
        Toast.makeText(getApplicationContext(), R.string.settings_restored, Toast.LENGTH_SHORT).show();
        return true;
    case android.R.id.home:
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.amfontai.cmput301asn1.NoteDetail.java

/**
 * Reads in the selected menu item/*from   w w w.j  a  va2 s.  c  om*/
 * and performs the appropriate task.
 * 
 * @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem)
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // This ID represents the Home or Up button. In the case of this
        // activity, the Up button is shown. Use NavUtils to allow users
        // to navigate up one level in the application structure. For
        // more details, see the Navigation pattern on Android Design:
        //
        // http://developer.android.com/design/patterns/navigation.html#up-vs-back
        //

        NavUtils.navigateUpFromSameTask(this);
        return true;
    case R.id.action_trash:
        deleteNote();
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.lacolaco.smileessence.activity.EditCommandActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_edit_command_all_on: {
        enableAll();/*  w  ww. ja  v a2s.c  o  m*/
        break;
    }
    case android.R.id.home: {
        NavUtils.navigateUpFromSameTask(this);
        return true;
    }
    }
    return true;
}