Example usage for android.app Activity getApplication

List of usage examples for android.app Activity getApplication

Introduction

In this page you can find the example usage for android.app Activity getApplication.

Prototype

public final Application getApplication() 

Source Link

Document

Return the application that owns this activity.

Usage

From source file:com.android.tests.lib.LibUnitTest.java

@Test
public void mockFinalMethod() {
    Activity activity = mock(Activity.class);
    Application app = mock(Application.class);
    when(activity.getApplication()).thenReturn(app);

    assertSame(app, activity.getApplication());

    verify(activity).getApplication();/*w w  w  .j a  v  a 2s.  c om*/
    verifyNoMoreInteractions(activity);
}

From source file:com.bushstar.kobocoin_android_wallet.ui.WalletDisclaimerFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = activity;
    final WalletApplication application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
}

From source file:cc.mintcoin.wallet.ui.WalletAddressFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (FragmentActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.nfcManager = (NfcManager) activity.getSystemService(Context.NFC_SERVICE);
}

From source file:com.microsoft.onedrive.apiexplorer.DeltaFragment.java

/**
 * Refresh the UI/*w  ww  .  jav a  2  s.  c  o m*/
 */
private void refresh() {
    if (getView() != null) {
        getView().findViewById(android.R.id.progress).setVisibility(View.VISIBLE);
        final TextView jsonView = (TextView) getView().findViewById(R.id.json);
        jsonView.setVisibility(View.INVISIBLE);
        jsonView.setText("");
        mCurrentPagesCount.set(0);
    }

    final String deltaToken = getDeltaInfo().getString(mItemId, null);
    final Activity activity = getActivity();
    ((BaseApplication) activity.getApplication()).getOneDriveClient().getDrive().getItems(mItemId)
            .getDelta(deltaToken).buildRequest().select("id,name,deleted").get(pageHandler());
}

From source file:cc.mintcoin.wallet.ui.WalletDisclaimerFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (WalletActivity) activity;
    final WalletApplication application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
}

From source file:piuk.blockchain.android.ui.WalletBalanceFragment.java

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

    final Activity activity = getActivity();
    application = (WalletApplication) activity.getApplication();
    prefs = PreferenceManager.getDefaultSharedPreferences(activity);

    EventListeners.addEventListener(eventListener);
}

From source file:de.schildbach.wallet.ui.EditTransactionNoteFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = activity;
    this.contentResolver = activity.getContentResolver();
    this.prefs = PreferenceManager.getDefaultSharedPreferences(activity.getApplication());
}

From source file:com.feathercoin.wallet.feathercoin.ui.WalletAddressFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (FragmentActivity) activity;
    prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    application = (WalletApplication) activity.getApplication();
}

From source file:systems.soapbox.ombuds.client.ui.WalletAddressFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = activity;
    this.application = (WalletApplication) activity.getApplication();
    this.config = application.getConfiguration();
    this.loaderManager = getLoaderManager();
}

From source file:com.nextgis.maplibui.formcontrol.TextEdit.java

@Override
public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor,
        SharedPreferences preferences) throws JSONException {
    ControlHelper.setClearAction(this);

    JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
    mFieldName = attributes.getString(JSON_FIELD_NAME_KEY);
    mIsShowLast = ControlHelper.isSaveLastValue(attributes);
    boolean enabled = ControlHelper.isEnabled(fields, mFieldName);

    String value = null;/*from w  w  w  . j  av a  2  s  .c  om*/
    if (ControlHelper.hasKey(savedState, mFieldName))
        value = savedState.getString(ControlHelper.getSavedStateKey(mFieldName));
    else if (null != featureCursor) { // feature exists
        int column = featureCursor.getColumnIndex(mFieldName);
        if (column >= 0)
            value = featureCursor.getString(column);
    } else { // new feature
        if (attributes.has(JSON_TEXT_KEY) && !attributes.isNull(JSON_TEXT_KEY))
            value = attributes.getString(JSON_TEXT_KEY);

        if (mIsShowLast)
            value = preferences.getString(mFieldName, value);
    }

    boolean useLogin = attributes.optBoolean(USE_LOGIN);
    String accountName = element.optString(SyncStateContract.Columns.ACCOUNT_NAME);
    if (useLogin && !TextUtils.isEmpty(accountName)) {
        enabled = false;
        Activity activity = ControlHelper.getActivity(getContext());
        if (activity != null) {
            GISApplication app = (GISApplication) activity.getApplication();
            Account account = app.getAccount(accountName);
            value = app.getAccountLogin(account);
        }
    }

    setEnabled(enabled);
    setText(value);

    //let's create control
    int maxLines = attributes.getInt(JSON_MAX_STRING_COUNT_KEY);
    if (maxLines < 2) {
        setSingleLine(true);
    } else {
        setMaxLines(maxLines);
    }

    int fieldType = NOT_FOUND;
    for (Field field : fields) {
        if (field.getName().equals(mFieldName)) {
            fieldType = field.getType();
            break;
        }
    }

    boolean onlyFigures = attributes.getBoolean(JSON_ONLY_FIGURES_KEY);
    if (onlyFigures) {
        //check field type
        switch (fieldType) {
        default:
        case GeoConstants.FTInteger:
            setInputType(InputType.TYPE_CLASS_NUMBER);
            break;

        case GeoConstants.FTReal:
            setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            break;
        }
    }
}