Example usage for android.content Intent ACTION_INSERT

List of usage examples for android.content Intent ACTION_INSERT

Introduction

In this page you can find the example usage for android.content Intent ACTION_INSERT.

Prototype

String ACTION_INSERT

To view the source code for android.content Intent ACTION_INSERT.

Click Source Link

Document

Activity Action: Insert an empty item into the given container.

Usage

From source file:net.ddns.mlsoftlaberge.mlsoft.contacts.ContactsListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    // Sends a request to the People app to display the create contact screen
    case R.id.menu_add_contact:
        final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
        startActivity(intent);//w w  w  .ja va 2 s.  c om
        break;
    // For platforms earlier than Android 3.0, triggers the search activity
    case R.id.menu_search:
        if (!Utils.hasHoneycomb()) {
            getActivity().onSearchRequested();
        }
        break;
    // Sends a request to the People app to display the create contact screen
    case R.id.menu_starred:
        // switch the starred flag on/off
        if (starredfind == 0) {
            starredfind = 1;
            item.setIcon(R.drawable.btn_star_big_on);
        } else {
            starredfind = 0;
            item.setIcon(R.drawable.btn_star_big_off);
        }
        // reread the list with new flag
        getLoaderManager().restartLoader(ContactsQuery.QUERY_ID, null, ContactsListFragment.this);
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.etuldan.sparss.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;//from   ww w  .java 2 s .  c  om
    mDrawerAdapter.setSelectedItem(position);
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }

        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.welcome_title).setItems(new CharSequence[] {
                getString(R.string.google_news_title), getString(R.string.add_custom_feed) },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 1) {
                            startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                        } else {
                            startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                        }
                    }
                });
        builder.show();
    }
    refreshTitle(0);
}

From source file:org.gnucash.android.test.ui.TransactionsActivityTest.java

public void testIntentTransactionRecording() {
    TransactionsDbAdapter trxnAdapter = new TransactionsDbAdapter(getActivity());
    int beforeCount = trxnAdapter.getTransactionsCount(trxnAdapter.getAccountID(DUMMY_ACCOUNT_UID));
    Intent transactionIntent = new Intent(Intent.ACTION_INSERT);
    transactionIntent.setType(Transaction.MIME_TYPE);
    transactionIntent.putExtra(Intent.EXTRA_TITLE, "Power intents");
    transactionIntent.putExtra(Intent.EXTRA_TEXT, "Intents for sale");
    transactionIntent.putExtra(Transaction.EXTRA_AMOUNT, 4.99);
    transactionIntent.putExtra(Transaction.EXTRA_ACCOUNT_UID, DUMMY_ACCOUNT_UID);

    getActivity().sendBroadcast(transactionIntent);

    mSolo.sleep(2000);//from   www .  j  a  v a2 s  .co m

    int afterCount = trxnAdapter.getTransactionsCount(trxnAdapter.getAccountID(DUMMY_ACCOUNT_UID));

    assertEquals(beforeCount + 1, afterCount);

    List<Transaction> transactions = trxnAdapter.getAllTransactionsForAccount(DUMMY_ACCOUNT_UID);

    for (Transaction transaction : transactions) {
        if (transaction.getName().equals("Power intents")) {
            assertEquals("Intents for sale", transaction.getDescription());
            assertEquals(4.99, transaction.getAmount().asDouble());
        }
    }

    trxnAdapter.close();
}

From source file:com.money.manager.ex.fragment.AccountFragment.java

/**
 * start the activity of transaction management
 * /*from   w ww.j  a  v a  2s  . co m*/
 * @param transId
 *            null set if you want to do a new transaction, or transaction id
 */
private void startCheckingAccountActivity(Integer transId) {
    // create intent, set Account ID
    Intent intent = new Intent(getActivity(), CheckingAccountActivity.class);
    intent.putExtra(CheckingAccountActivity.KEY_ACCOUNT_ID, mAccountId);
    // check transId not null
    if (transId != null) {
        intent.putExtra(CheckingAccountActivity.KEY_TRANS_ID, transId);
        intent.setAction(Intent.ACTION_EDIT);
    } else {
        intent.setAction(Intent.ACTION_INSERT);
    }
    // launch activity
    startActivity(intent);
}

From source file:edu.mit.mobile.android.locast.itineraries.ItineraryDetail.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.add_cast:
        startActivity(new Intent(Intent.ACTION_INSERT, Itinerary.getCastsUri(getIntent().getData())));
        return true;

    case R.id.refresh:
        refresh(true);//from www .j  ava2 s  . co  m
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.money.manager.ex.notifications.SmsReceiverTransactions.java

@Override
public void onReceive(Context context, Intent intent) {
    mContext = context.getApplicationContext();

    final BehaviourSettings behav_settings = new BehaviourSettings(mContext);
    final GeneralSettings gen_settings = new GeneralSettings(mContext);
    final AppSettings app_settings = new AppSettings(mContext);
    final PreferenceConstants prf_const = new PreferenceConstants();

    //App Settings
    int baseCurencyID, fromCurrencyID, toCurrencyID;
    int baseAccountID, fromAccountID, toAccountID;

    String baseCurrencySymbl, fromAccCurrencySymbl, toAccCurrencySymbl;
    String baseAccountName, fromAccountName, toAccountName;

    Boolean autoTransactionStatus = false;
    Boolean skipSaveTrans = false;

    try {//from  w w w  .j a v a 2s  .co  m
        //------- if settings enabled the parse the sms and create trans ---------------
        if (behav_settings.getBankSmsTrans() == true) {

            //---get the SMS message passed in---
            Bundle bundle = intent.getExtras();
            SmsMessage[] msgs = null;
            String msgBody = "";
            String msgSender = "";

            if (bundle != null) { //---retrieve the SMS message received---

                Object[] pdus = (Object[]) bundle.get("pdus");
                msgs = new SmsMessage[pdus.length];

                for (int i = 0; i < msgs.length; i++) {
                    msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                    msgSender = msgs[i].getOriginatingAddress();
                    msgBody += msgs[i].getMessageBody().toString();
                }

                //msgSender = "AT-SIBSMS";

                if (isTransactionSms(msgSender)) {
                    // Transaction Sms sender will have format like this AT-SIBSMS,
                    // Promotional sms will have sender like AT-012345
                    // Not sure how this format will be in out side of India. May I need to update if i get sample

                    ITransactionEntity model = AccountTransaction.create();
                    mCommon = new EditTransactionCommonFunctions(null, model, database);

                    // find out the trans type using reg ex
                    String[] key_credit_search = { "(credited)", "(received)", "(added)", "(reloaded)",
                            "(deposited)", "(refunded)", "(debited)(.*?)(towards)(\\s)",
                            "(\\s)(received)(.*?)(in(\\s)your)(\\s)", "(sent)(.*?)(to)(\\s)",
                            "(debited)(.*?)(to)(\\s)", "(credited)(.*?)(in)(\\s)", "(credited)(.*?)(to)(\\s)" };

                    String[] key_debit_search = { "(made)", "(debited)", "(using)", "(paid)", "(purchase)",
                            "(withdrawn)", "(credited)(.*?)(from)(\\s)", "(sent)(.*?)(from)(\\s)",
                            "(\\s)(received)(.*?)(from)(\\s)" };

                    String transType = "";

                    Boolean isDeposit = validateTransType(key_credit_search, msgBody.toLowerCase());
                    Boolean isWithdrawal = validateTransType(key_debit_search, msgBody.toLowerCase());

                    if (isDeposit == true) {
                        if (isWithdrawal == true) {
                            transType = "Transfer";
                            String[] transCategory = getCategoryOrSubCategoryByName("Transfer");

                            if (!transCategory[0].isEmpty()) {
                                mCommon.transactionEntity.setCategoryId(parseInt(transCategory[0]));
                            }

                            if (!transCategory[1].isEmpty()) {
                                mCommon.transactionEntity.setSubcategoryId(parseInt(transCategory[1]));
                            }

                            mCommon.transactionEntity.setTransactionType(TransactionTypes.Transfer);

                        } else {
                            transType = "Deposit";
                            String[] incomeCategory = getCategoryOrSubCategoryByName("Income");

                            if (!incomeCategory[0].isEmpty()) {
                                mCommon.transactionEntity.setCategoryId(parseInt(incomeCategory[0]));
                            }

                            if (!incomeCategory[1].isEmpty()) {
                                mCommon.transactionEntity.setSubcategoryId(parseInt(incomeCategory[1]));
                            }

                            mCommon.transactionEntity.setTransactionType(TransactionTypes.Deposit);
                        }

                    } else if (isWithdrawal == true) {
                        transType = "Withdrawal";
                        mCommon.transactionEntity.setTransactionType(TransactionTypes.Withdrawal);
                    }

                    mCommon.transactionEntity.setStatus("");
                    mCommon.payeeName = "";

                    if (transType != "" && msgBody.toLowerCase().contains("otp") == false) { // if not from blank, then nothing to do with sms

                        //Create the intent thatll fire when the user taps the notification//
                        Intent t_intent = new Intent(mContext, CheckingTransactionEditActivity.class);

                        // Db setup
                        MmxHelper = new MmxOpenHelper(mContext,
                                app_settings.getDatabaseSettings().getDatabasePath());
                        db = MmxHelper.getReadableDatabase();

                        baseCurencyID = gen_settings.getBaseCurrencytId();
                        baseAccountID = gen_settings.getDefaultAccountId();
                        baseAccountName = "";
                        fromAccountID = -1;
                        fromCurrencyID = -1;
                        fromAccountName = "";

                        //if default account id selected
                        if (baseAccountID > 0) {
                            fromAccountID = baseAccountID;
                            fromAccountName = baseAccountName;
                            fromCurrencyID = baseCurencyID;
                        }

                        //Get the base currency sysmbl
                        baseCurrencySymbl = getCurrencySymbl(baseCurencyID);
                        fromAccCurrencySymbl = baseCurrencySymbl;

                        //get te from acount details
                        extractAccountDetails(msgBody, transType);

                        if (!fromAccountDetails[0].isEmpty()) {
                            fromAccountID = parseInt(fromAccountDetails[0]);
                            fromAccountName = fromAccountDetails[1];
                            fromCurrencyID = parseInt(fromAccountDetails[2]);
                            fromAccCurrencySymbl = fromAccountDetails[3];
                            mCommon.transactionEntity.setAccountId(fromAccountID);
                        }

                        mCommon.transactionEntity.setNotes(msgBody);
                        mCommon.transactionEntity.setDate(new MmxDate().toDate());

                        //get the trans amount
                        String transAmount = extractTransAmount(msgBody, fromAccCurrencySymbl);
                        String[] transPayee = extractTransPayee(msgBody);

                        //If there is no account no. or payee in the msg & no amt, then this is not valid sms to do transaction
                        if ((!fromAccountDetails[6].isEmpty() || !toAccountDetails[6].isEmpty()
                                || !transPayee[0].isEmpty()) && !transAmount.isEmpty()) {

                            mCommon.transactionEntity.setAmount(MoneyFactory.fromString(transAmount));

                            String transRefNo = extractTransRefNo(msgBody);

                            //set the ref no. if exists
                            if (!transRefNo.isEmpty()) {
                                mCommon.transactionEntity.setTransactionNumber(transRefNo);
                            }

                            int txnId = getTxnId(transRefNo.trim(), mCommon.transactionEntity.getDateString());

                            switch (txnId) {
                            case 0: //add new trnsaction

                                if (transType == "Transfer") //if it is transfer
                                {
                                    if (!toAccountDetails[0].isEmpty()) // if id exists then considering as account transfer
                                    {
                                        toAccountID = parseInt(toAccountDetails[0]);
                                        toAccountName = toAccountDetails[1];
                                        toCurrencyID = parseInt(toAccountDetails[2]);
                                        toAccCurrencySymbl = toAccountDetails[3];

                                        mCommon.transactionEntity.setAccountToId(toAccountID);

                                        //convert the to amount from the both currency details
                                        CurrencyService currencyService = new CurrencyService(mContext);
                                        mCommon.transactionEntity
                                                .setAmountTo(currencyService.doCurrencyExchange(fromCurrencyID,
                                                        mCommon.transactionEntity.getAmount(), toCurrencyID));

                                        mCommon.transactionEntity.setPayeeId(Constants.NOT_SET);

                                    } else { // if not, then IMPS transfer tp 3rd party

                                        transType = "Withdrawal";
                                        mCommon.transactionEntity
                                                .setTransactionType(TransactionTypes.Withdrawal);
                                        mCommon.transactionEntity.setAccountToId(Constants.NOT_SET);
                                        mCommon.transactionEntity
                                                .setAmountTo(MoneyFactory.fromString(transAmount));

                                        //if there is no to account found from mmex db, then check for payee
                                        //This will helps me to handle 3rd party transfer thru IMPS
                                        if (!toAccountDetails[6].isEmpty() && transPayee[0].isEmpty()) {
                                            transPayee = getPayeeDetails(toAccountDetails[6].trim());
                                        }
                                    }
                                } else {
                                    mCommon.transactionEntity.setAccountToId(Constants.NOT_SET);
                                    mCommon.transactionEntity.setAmountTo(MoneyFactory.fromString(transAmount));
                                }

                                if (!transPayee[0].isEmpty()) {

                                    mCommon.transactionEntity.setPayeeId(parseInt(transPayee[0]));
                                    mCommon.payeeName = transPayee[1];
                                    mCommon.transactionEntity.setCategoryId(parseInt(transPayee[2]));
                                    mCommon.transactionEntity.setSubcategoryId(parseInt(transPayee[3]));
                                }

                                t_intent.setAction(Intent.ACTION_INSERT); //Set the action

                                break;

                            default: //Update existing transaction

                                transType = "Transfer";

                                AccountTransactionRepository repo = new AccountTransactionRepository(mContext);
                                AccountTransaction txn = repo.load(txnId);

                                if (txn != null) {

                                    if (txn.getTransactionType() != TransactionTypes.Transfer) {

                                        AccountRepository accountRepository = new AccountRepository(mContext);

                                        if (txn.getTransactionType() == TransactionTypes.Deposit) {
                                            toAccountID = txn.getAccountId();
                                            toCurrencyID = accountRepository
                                                    .loadCurrencyIdFor(txn.getAccountId());
                                        } else {
                                            toAccountID = fromAccountID;
                                            toCurrencyID = fromCurrencyID;
                                            fromCurrencyID = accountRepository
                                                    .loadCurrencyIdFor(txn.getAccountId());
                                        }

                                        mCommon.transactionEntity = txn;
                                        mCommon.transactionEntity.setTransactionType(TransactionTypes.Transfer);
                                        mCommon.transactionEntity.setAccountId(fromAccountID);
                                        mCommon.transactionEntity.setAccountToId(toAccountID);

                                        //convert the to amount from the both currency details
                                        CurrencyService currencyService = new CurrencyService(mContext);
                                        mCommon.transactionEntity
                                                .setAmountTo(currencyService.doCurrencyExchange(fromCurrencyID,
                                                        mCommon.transactionEntity.getAmount(), toCurrencyID));

                                        mCommon.transactionEntity.setPayeeId(Constants.NOT_SET);

                                        String[] transCategory = getCategoryOrSubCategoryByName("Transfer");
                                        if (!transCategory[0].isEmpty()) {
                                            mCommon.transactionEntity.setCategoryId(parseInt(transCategory[0]));
                                            mCommon.transactionEntity
                                                    .setSubcategoryId(parseInt(transCategory[1]));
                                        }

                                        mCommon.transactionEntity.setNotes(
                                                mCommon.transactionEntity.getNotes() + "\n\n" + msgBody);

                                        t_intent.setAction(Intent.ACTION_EDIT); //Set the action
                                    } else //if transfer already exists, then do nothing
                                    {
                                        skipSaveTrans = true;
                                    }

                                }

                            }

                            // Capture the details the for Toast
                            String strExtracted = "Account = " + fromAccountName + "-" + fromAccountDetails[6]
                                    + "\n" + "Trans Amt = " + fromAccCurrencySymbl + " " + transAmount + ",\n"
                                    + "Payyee Name= " + transPayee[1] + "\n" + "Category ID = " + transPayee[2]
                                    + "\n" + "Sub Category ID = " + transPayee[3] + "\n" + "Trans Ref No. = "
                                    + transRefNo + "\n" + "Trans Type = " + transType + "\n";

                            //Must be commented for released version
                            //mCommon.transactionEntity.setNotes(strExtracted);

                            // Set the content for a transaction);
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,
                                    "SmsReceiverTransactions.java");
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_ID,
                                    mCommon.transactionEntity.getId());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_ACCOUNT_ID,
                                    String.valueOf(mCommon.transactionEntity.getAccountId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TO_ACCOUNT_ID,
                                    String.valueOf(mCommon.transactionEntity.getAccountToId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_CODE,
                                    mCommon.getTransactionType());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_PAYEE_ID,
                                    String.valueOf(mCommon.transactionEntity.getPayeeId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_PAYEE_NAME,
                                    mCommon.payeeName);
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_CATEGORY_ID,
                                    String.valueOf(mCommon.transactionEntity.getCategoryId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_SUBCATEGORY_ID,
                                    String.valueOf(mCommon.transactionEntity.getSubcategoryId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_AMOUNT,
                                    String.valueOf(mCommon.transactionEntity.getAmount()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_NOTES,
                                    mCommon.transactionEntity.getNotes());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_DATE,
                                    new MmxDate().toDate());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_NUMBER,
                                    mCommon.transactionEntity.getTransactionNumber());

                            // validate and save the transaction
                            if (skipSaveTrans == false) {
                                if (validateData()) {
                                    if (saveTransaction()) {
                                        Toast.makeText(context,
                                                "MMEX: Bank Transaction Processed for: \n\n" + strExtracted,
                                                Toast.LENGTH_LONG).show();
                                        autoTransactionStatus = true;
                                    }
                                }

                                //if transaction is not created automatically, then invoke notification or activity screen
                                if (autoTransactionStatus == false) {
                                    startActivity(mContext, t_intent, null);
                                    //showNotification(t_intent, strExtracted);
                                }
                            } else {
                                Toast.makeText(context,
                                        "MMEX: Skiping Bank Transaction updates SMS, because transaction exists with ref. no. "
                                                + transRefNo,
                                        Toast.LENGTH_LONG).show();
                            }

                            //reset the value
                            msgBody = "";
                            msgSender = "";
                            bundle = null;
                            msgs = null;
                            mCommon = null;
                            skipSaveTrans = false;

                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        Timber.e(e, "MMEX: Bank Transaction Process EXCEPTION");
    }
}

From source file:com.money.manager.ex.investment.watchlist.WatchlistItemsFragment.java

private void openEditInvestmentActivity() {
    Intent intent = new Intent(getActivity(), InvestmentTransactionEditActivity.class);
    intent.putExtra(InvestmentTransactionEditActivity.ARG_ACCOUNT_ID, this.accountId);
    intent.setAction(Intent.ACTION_INSERT);
    startActivity(intent);/* w w w .j av a2s .c o m*/
}

From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionListFragment.java

private void showCreateTransactionActivity(int recurringTransactionId) {
    RecurringTransactionRepository repo = new RecurringTransactionRepository(getActivity());
    RecurringTransaction tx = repo.load(recurringTransactionId);
    if (tx == null)
        return;/*from  w w w  .jav a 2  s . c  om*/

    Intent intent = new Intent(getActivity(), CheckingTransactionEditActivity.class);
    intent.setAction(Intent.ACTION_INSERT);
    intent.putExtra(EditTransactionActivityConstants.KEY_BDID_ID, recurringTransactionId);
    // start for insert new transaction
    startActivityForResult(intent, REQUEST_ADD_TRANSACTION);
}

From source file:com.nononsenseapps.notepad.ActivityMain.java

/**
 * Returns a list id from an intent if it contains one, either as part of
 * its URI or as an extra//from   w  w  w  . j  av a2  s. c o m
 * <p/>
 * Returns -1 if no id was contained, this includes insert actions
 */
long getListId(final Intent intent) {
    long retval = -1;
    if (intent != null && intent.getData() != null
            && (Intent.ACTION_EDIT.equals(intent.getAction()) || Intent.ACTION_VIEW.equals(intent.getAction())
                    || Intent.ACTION_INSERT.equals(intent.getAction()))) {
        if ((intent.getData().getPath().startsWith(NotePad.Lists.PATH_VISIBLE_LISTS)
                || intent.getData().getPath().startsWith(NotePad.Lists.PATH_LISTS)
                || intent.getData().getPath().startsWith(TaskList.URI.getPath()))) {
            try {
                retval = Long.parseLong(intent.getData().getLastPathSegment());
            } catch (NumberFormatException e) {
                retval = -1;
            }
        } else if (-1 != intent.getLongExtra(LegacyDBHelper.NotePad.Notes.COLUMN_NAME_LIST, -1)) {
            retval = intent.getLongExtra(LegacyDBHelper.NotePad.Notes.COLUMN_NAME_LIST, -1);
        } else if (-1 != intent.getLongExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, -1)) {
            retval = intent.getLongExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, -1);
        } else if (-1 != intent.getLongExtra(Task.Columns.DBLIST, -1)) {
            retval = intent.getLongExtra(Task.Columns.DBLIST, -1);
        }
    }
    return retval;
}

From source file:social.news.inrss.activity.HomeActivity.java

private void selectDrawerItem(int position) {
    mCurrentDrawerPos = position;/*from   w  w  w  .j  a  va2  s  .c om*/

    if (mDrawerAdapter == null)
        return;

    mDrawerAdapter.setSelectedItem(position);
    mIcon = null;

    Uri newUri;
    boolean showFeedInfo = true;

    switch (position) {
    case SEARCH_DRAWER_POSITION:
        newUri = EntryColumns.SEARCH_URI(mEntriesFragment.getCurrentSearch());
        break;
    case 0:
        newUri = EntryColumns.ALL_ENTRIES_CONTENT_URI;
        break;
    case 1:
        newUri = EntryColumns.FAVORITES_CONTENT_URI;
        break;
    default:
        long feedOrGroupId = mDrawerAdapter.getItemId(position);
        if (mDrawerAdapter.isItemAGroup(position)) {
            newUri = EntryColumns.ENTRIES_FOR_GROUP_CONTENT_URI(feedOrGroupId);
        } else {
            byte[] iconBytes = mDrawerAdapter.getItemIcon(position);
            Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24);
            if (bitmap != null) {
                mIcon = new BitmapDrawable(getResources(), bitmap);
            }

            newUri = EntryColumns.ENTRIES_FOR_FEED_CONTENT_URI(feedOrGroupId);
            showFeedInfo = false;
        }

        mTitle = mDrawerAdapter.getItemName(position);
        break;
    }

    if (!newUri.equals(mEntriesFragment.getUri())) {
        mEntriesFragment.setData(newUri, showFeedInfo);
    }

    mDrawerList.setItemChecked(position, true);

    // First open => we open the drawer for you
    if (PrefUtils.getBoolean(PrefUtils.FIRST_OPEN, true)) {
        PrefUtils.putBoolean(PrefUtils.FIRST_OPEN, false);
        if (mDrawerLayout != null) {
            mDrawerLayout.postDelayed(new Runnable() {
                @Override
                public void run() {
                    mDrawerLayout.openDrawer(mLeftDrawer);
                }
            }, 500);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.welcome_title).setItems(new CharSequence[] {
                getString(R.string.google_news_title), getString(R.string.add_custom_feed) },
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (which == 1) {
                            startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI));
                        } else {
                            startActivity(new Intent(HomeActivity.this, AddGoogleNewsActivity.class));
                        }
                    }
                });
        builder.show();
    }
    refreshTitle(0);
}