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:com.money.manager.ex.home.HomeFragment.java

private void createWelcomeView(View view) {
    linearWelcome = (ViewGroup) view.findViewById(R.id.linearLayoutWelcome);

    // basic preferences
    Button buttonSettings = (Button) view.findViewById(R.id.buttonSettings);
    if (buttonSettings != null) {
        buttonSettings.setOnClickListener(new OnClickListener() {
            @Override//from  ww w.  j  a  va2 s. com
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), SettingsActivity.class));
            }
        });
    }

    // Show current database
    TextView currentDatabaseTextView = (TextView) view.findViewById(R.id.currentDatabaseTextView);
    if (currentDatabaseTextView != null) {
        String path = MoneyManagerApplication.getDatabasePath(getActivity());
        currentDatabaseTextView.setText(path);
    }

    // add account button
    Button btnAddAccount = (Button) view.findViewById(R.id.buttonAddAccount);
    if (btnAddAccount != null) {
        btnAddAccount.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), AccountEditActivity.class);
                intent.setAction(Intent.ACTION_INSERT);
                startActivity(intent);
            }
        });
    }

    // Database migration v1.4 -> v2.0 location.
    setUpMigrationButton(view);
}

From source file:com.android.contacts.activities.ContactSelectionActivity.java

private void startCreateNewContactActivity() {
    Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
    intent.putExtra(ContactEditorActivity.INTENT_KEY_FINISH_ACTIVITY_ON_SAVE_COMPLETED, true);
    startActivityAndForwardResult(intent);
}

From source file:org.andstatus.app.account.AccountSettingsActivity.java

public static void startAddNewAccount(android.content.Context context) {
    Intent intent;/*from w  w  w . ja va2  s . c o  m*/
    intent = new Intent(context, AccountSettingsActivity.class);
    intent.setAction(Intent.ACTION_INSERT);
    context.startActivity(intent);
}

From source file:org.hfoss.posit.android.api.fragment.FindFragment.java

/**
 * When we get a fresh location, update our class variable..
 *//*from   w ww. j av  a2s. c  o m*/
public void onLocationChanged(Location location) {
    if (isBetterLocation(location, mCurrentLocation)) {
        mCurrentLocation = location;
        // if we are creating a new find update the location as we get updates
        if (getAction().equals(Intent.ACTION_INSERT)) {
            if (mLongitudeTV != null)
                mLongitudeTV.setText(String.valueOf(mCurrentLocation.getLongitude()));
            if (mLatitudeTV != null)
                mLatitudeTV.setText(String.valueOf(mCurrentLocation.getLatitude()));

        }
        Log.i(TAG, "Got a new location: " + mCurrentLocation.getLatitude() + ","
                + mCurrentLocation.getLongitude());
    }
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.editor.TaskDetailFragment.java

void fixIntent() {
    stateId = mTask._id;/*  w w  w. ja  v  a2s.  com*/
    stateListId = mTask.dblist;

    if (getActivity() == null)
        return;

    final Intent orgIntent = getActivity().getIntent();
    if (orgIntent == null || orgIntent.getAction() == null
            || !orgIntent.getAction().equals(Intent.ACTION_INSERT))
        return;

    if (mTask == null || mTask._id < 1)
        return;

    final Intent intent = new Intent().setAction(Intent.ACTION_EDIT)
            .setClass(getActivity(), ActivityEditor.class).setData(mTask.getUri())
            .putExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, mTask.dblist);

    getActivity().setIntent(intent);
}

From source file:com.android.contacts.activities.ContactDetailActivity.java

/**
 * M: call back for create or update group in ContactDetailActivity.
 *//*from w  ww  .  j a v a2s.c o m*/
@Override
public void onServiceCompleted(Intent callbackIntent) {
    // / M: add for group new feature @{
    String action = callbackIntent.getAction();

    if (ACTION_UPDATE_COMPLETED.equals(action)) {
        long mRawContactId = callbackIntent.getLongExtra(ContactSaveService.EXTRA_RAW_CONTACTS_ID, -1);
        if (mRawContactId <= 0) {
            LogUtils.i(TAG, "[onServiceCompleted] save contact groups rawcontact id is " + mRawContactId
                    + " Group changes save failed.");
            return;
        }
    } else if (Intent.ACTION_INSERT.equals(action)) {
        boolean createGroup = callbackIntent.getBooleanExtra(ContactSaveService.CREATE_GROUP_COMP, false);
        if (createGroup) {
            ContactDetailFragment detailFragment = mContactDetailLayoutController.getDetailFragment();
            String groupName = callbackIntent.getStringExtra(ContactSaveService.EXTRA_NEW_GROUP_NAME);
            LogUtils.i(TAG, "[onServiceCompleted] create new group's name == " + groupName);
            detailFragment.setCreateNewGroupName(groupName);
        }

        if (callbackIntent.getData() == null) {
            LogUtils.i(TAG, "[onServiceCompleted] save contact group data is null, Save failed.");
            return;
        }
    }

    // toast save successful.
    MtkToast.toast(this, R.string.groupSavedToast);

    onNewIntent(callbackIntent);

}

From source file:org.hfoss.posit.android.api.fragment.FindFragment.java

/**
 * Save the find which is displayed in the fragment
 * // ww w . jav a 2s.  c  o m
 * @return   success of saving the find
 */
@SuppressWarnings("unchecked")
protected boolean saveFind() {
    Log.i(TAG, "saveFind()");
    int rows = 0;
    Find find = retrieveContentFromView();
    prepareForSave(find);

    // A valid GUID is required
    if (!isValidGuid(find.getGuid())) {
        Toast.makeText(getActivity(), "You must provide a valid Id for this Find.", Toast.LENGTH_LONG).show();
        return false;
    }

    // A name is not always required in derived classes
    String name = find.getName();
    if (name != null && name.equals("")) {
        // if (find.getName().equals("")){
        Toast.makeText(getActivity(), "You must provide a name for this Find.", Toast.LENGTH_LONG).show();
        return false;
    }

    // Either create a new Find or update the existing Find
    if (getAction().equals(Intent.ACTION_INSERT))
        rows = getHelper().insert(find);
    else if (getAction().equals(Intent.ACTION_EDIT)) {
        find.setId(getArguments().getInt(Find.ORM_ID));
        find.setStatus(Find.IS_NOT_SYNCED);
        rows = getHelper().update(find);
    } else if (getAction().equals(Intent.ACTION_INSERT_OR_EDIT)) {
        // Check if a Find with the same GUID already exists and update it if so
        Find sameguid = getHelper().getFindByGuid(find.getGuid());
        if (sameguid == null) {
            rows = getHelper().insert(find);
        } else {
            find.setId(sameguid.getId());
            rows = getHelper().update(find);
        }
    } else
        rows = 0; // Something wrong with intent

    if (rows > 0) {
        Log.i(TAG, "Find " + getAction() + " successful: " + find);
    } else
        Log.e(TAG, "Find " + getAction() + " not successful: " + find);

    /**
     * For each plugin, call its displayFindInViewCallback.
     */
    for (FunctionPlugin plugin : mAddFindMenuPlugins) {
        Log.i(TAG, "plugin=" + plugin);
        Class<AddFindPluginCallback> callbackClass = null;
        Object o;
        try {
            View view = getView();
            String className = plugin.getAddFindCallbackClass();
            if (className != null) {
                callbackClass = (Class<AddFindPluginCallback>) Class.forName(className);
                o = (AddFindPluginCallback) callbackClass.newInstance();
                ((AddFindPluginCallback) o).afterSaveCallback(getActivity().getApplication(), find, view,
                        rows > 0);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (java.lang.InstantiationException e) {
            e.printStackTrace();
        }
    }
    return rows > 0;
}

From source file:com.money.manager.ex.common.AllDataListFragment.java

/**
 * start the activity of transaction management
 *
 * @param transId null set if you want to do a new transaction, or transaction id
 *///from  www .j  av a  2  s .  com
private void startEditAccountTransactionActivity(Integer transId) {
    // create intent, set Account ID
    Intent intent = new Intent(getActivity(), CheckingTransactionEditActivity.class);
    // check transId not null
    if (transId != null) {
        intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_ID, transId);
        intent.setAction(Intent.ACTION_EDIT);
    } else {
        intent.putExtra(EditTransactionActivityConstants.KEY_ACCOUNT_ID, this.AccountId);
        intent.setAction(Intent.ACTION_INSERT);
    }
    // launch activity
    startActivity(intent);
}

From source file:com.money.manager.ex.account.AccountTransactionListFragment.java

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