Example usage for android.os Bundle EMPTY

List of usage examples for android.os Bundle EMPTY

Introduction

In this page you can find the example usage for android.os Bundle EMPTY.

Prototype

Bundle EMPTY

To view the source code for android.os Bundle EMPTY.

Click Source Link

Usage

From source file:com.github.michalbednarski.intentslab.providerlab.AdvancedQueryActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.advanced_query);

    Intent intent = getIntent();//from w  w w  . j a  v  a2  s.co  m
    Bundle instanceStateOrExtras = savedInstanceState != null ? savedInstanceState : intent.getExtras();
    if (instanceStateOrExtras == null) {
        instanceStateOrExtras = Bundle.EMPTY;
    }

    // Uri
    mUriTextView = (AutoCompleteTextView) findViewById(R.id.uri);
    if (intent.getData() != null) {
        mUriTextView.setText(intent.getDataString());
    }
    mUriTextView.setAdapter(new UriAutocompleteAdapter(this));

    // Projection
    {
        mSpecifyProjectionCheckBox = (CheckBox) findViewById(R.id.specify_projection);
        mProjectionLayout = (LinearLayout) findViewById(R.id.projection_columns);

        // Bind events for master CheckBox and add new button
        findViewById(R.id.new_projection_column).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new UserProjectionColumn("");
            }
        });
        mSpecifyProjectionCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mProjectionLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            }
        });

        // Get values to fill
        String[] availableProjectionColumns = intent.getStringArrayExtra(EXTRA_PROJECTION_AVAILABLE_COLUMNS);
        String[] specifiedProjectionColumns = instanceStateOrExtras.getStringArray(EXTRA_PROJECTION);

        if (specifiedProjectionColumns == null) {
            mSpecifyProjectionCheckBox.setChecked(false);
        }

        if (availableProjectionColumns != null && availableProjectionColumns.length == 0) {
            availableProjectionColumns = null;
        }
        if (availableProjectionColumns != null && specifiedProjectionColumns == null) {
            specifiedProjectionColumns = availableProjectionColumns;
        }

        // Create available column checkboxes
        int i = 0;
        if (availableProjectionColumns != null) {
            for (String availableProjectionColumn : availableProjectionColumns) {
                boolean isChecked = i < specifiedProjectionColumns.length
                        && availableProjectionColumn.equals(specifiedProjectionColumns[i]);
                new DefaultProjectionColumn(availableProjectionColumn, isChecked);
                if (isChecked) {
                    i++;
                }
            }
        }

        // Create user column text fields
        if (specifiedProjectionColumns != null && i < specifiedProjectionColumns.length) {
            for (int il = specifiedProjectionColumns.length; i < il; i++) {
                new UserProjectionColumn(specifiedProjectionColumns[i]);
            }
        }

    }

    // Selection
    {
        // Find views
        mSelectionCheckBox = (CheckBox) findViewById(R.id.selection_header);
        mSelectionText = (TextView) findViewById(R.id.selection);
        mSelectionLayout = findViewById(R.id.selection_layout);
        mSelectionArgsTable = (TableLayout) findViewById(R.id.selection_args);

        // Bind events for add button and master CheckBox
        findViewById(R.id.selection_add_arg).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new SelectionArg("", true);
            }
        });
        mSelectionCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mSelectionLayout.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            }
        });

        // Fill selection text view and CheckBox
        String selection = intent.getStringExtra(EXTRA_SELECTION);
        String[] selectionArgs = instanceStateOrExtras.getStringArray(EXTRA_SELECTION_ARGS);

        mSelectionCheckBox.setChecked(selection != null);
        if (selection != null) {
            mSelectionText.setText(selection);
        }

        // Fill selection arguments
        if ((selection != null || savedInstanceState != null) && selectionArgs != null
                && selectionArgs.length != 0) {
            for (String selectionArg : selectionArgs) {
                new SelectionArg(selectionArg);
            }
        }
    }

    // Content values
    {
        // Find views
        mContentValuesHeader = (TextView) findViewById(R.id.content_values_header);
        mContentValuesTable = (TableLayout) findViewById(R.id.content_values);
        mContentValuesTableHeader = (TableRow) findViewById(R.id.content_values_table_header);

        // Bind add new button event
        findViewById(R.id.new_content_value).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new ContentValue("", "", true);
            }
        });

        // Create table
        ContentValues contentValues = instanceStateOrExtras.getParcelable(EXTRA_CONTENT_VALUES);
        if (contentValues != null) {
            contentValues.valueSet();
            for (String key : Utils.getKeySet(contentValues)) {
                new ContentValue(key, contentValues.getAsString(key));
            }
        }
    }

    // Order
    {
        // Find views
        mSpecifyOrderCheckBox = (CheckBox) findViewById(R.id.specify_order);
        mOrderTextView = (TextView) findViewById(R.id.order);

        // Bind events
        mSpecifyOrderCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mOrderTextView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
            }
        });

        // Fill fields
        String order = intent.getStringExtra(EXTRA_SORT_ORDER);
        if (order == null) {
            mSpecifyOrderCheckBox.setChecked(false);
        } else {
            mOrderTextView.setText(order);
        }
    }

    // Method (affects previous views so they must be initialized first)
    mMethodSpinner = (Spinner) findViewById(R.id.method);
    mMethodSpinner
            .setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, METHOD_NAMES));
    mMethodSpinner.setOnItemSelectedListener(onMethodSpinnerItemSelectedListener);
    mMethodSpinner.setSelection(intent.getIntExtra(EXTRA_METHOD, METHOD_QUERY));
}

From source file:com.google.android.demos.jamendo.widget.Loadable.java

/**
 * @see LoaderManager#restartLoader(int, Bundle, LoaderCallbacks)
 */
public void restart() {
    mLoaderManager.restartLoader(mLoaderId, Bundle.EMPTY, this);
}

From source file:com.google.android.feeds.ContentDecorator.java

private Bundle getCursorExtras() {
    if (mAdapter instanceof android.widget.CursorAdapter) {
        Cursor cursor = ((android.widget.CursorAdapter) mAdapter).getCursor();
        return cursor != null ? cursor.getExtras() : Bundle.EMPTY;
    } else if (isInstanceOfSupportCursorAdapter(mAdapter)) {
        Cursor cursor = supportGetCursor(mAdapter);
        return cursor != null ? cursor.getExtras() : Bundle.EMPTY;
    } else {//  ww  w.  jav  a 2 s .  c  om
        return Bundle.EMPTY;
    }
}

From source file:com.google.android.demos.rss.app.ChannelActivity.java

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

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.list_activity);
    ListView listView = (ListView) findViewById(android.R.id.list);
    mEmpty = findViewById(R.id.empty);/* w  w w. j  a v a2s .  c om*/
    mLoading = findViewById(R.id.loading);
    mError = findViewById(R.id.error);
    mError.findViewById(R.id.retry).setOnClickListener(this);

    // Loader from last Activity instance may still be loading
    mLoading.setVisibility(View.VISIBLE);
    mEmpty.setVisibility(View.GONE);
    mError.setVisibility(View.GONE);

    Context context = this;
    int layout = android.R.layout.simple_list_item_1;
    String[] from = { Items.TITLE };
    int[] to = { android.R.id.text1 };
    SimpleCursorAdapter innerAdapter = new SimpleCursorAdapter(context, layout, null, from, to);
    innerAdapter.setViewBinder(this);

    mAdapter = new ChannelAdapter(this);
    mAdapter.registerDataSetObserver(new TitleObserver());
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(this);
    getSupportLoaderManager().initLoader(LOADER_CHANNEL, Bundle.EMPTY, this);
}

From source file:ru.tinkoff.acquiring.sdk.CardListFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Item item = adapter.getItem(position);
    PayFormActivity activity = ((PayFormActivity) getActivity());
    Card card = (Card) item.obj;//from   www . j  a v a  2  s.co m

    if (actionMode != null && card != null) {
        actionMode.invalidate();
        adapter.setSelectedItemPosition(position);
        view.setSelected(true);
    } else if (actionMode != null) {
        actionMode.finish();
    } else {
        activity.getFragmentsCommunicator().setPendingResult(PayFormActivity.RESULT_CODE_CLEAR_CARD,
                Bundle.EMPTY);
        activity.setSourceCard(card);
        activity.finishChooseCards();
    }
}

From source file:org.peterbaldwin.vlcremote.fragment.ArtFragment.java

@Override
public void onNewMediaServer(MediaServer server) {
    super.onNewMediaServer(server);
    if (getMediaServer() != null) {
        getLoaderManager().restartLoader(LOADER_IMAGE, Bundle.EMPTY, this);
    }/*from   w w w .j  av a 2s. c o  m*/
}

From source file:com.android.mail.browse.EmlViewerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.eml_viewer_activity);

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final Intent intent = getIntent();
    final String action = intent.getAction();
    final String type = intent.getType();
    mAccountUri = intent.getParcelableExtra(EXTRA_ACCOUNT_URI);

    if (savedInstanceState == null) {
        if (Intent.ACTION_VIEW.equals(action) && MimeType.isEmlMimeType(type)) {
            final FragmentTransaction transaction = getFragmentManager().beginTransaction();
            transaction.add(R.id.eml_root, EmlMessageViewFragment.newInstance(intent.getData(), mAccountUri),
                    FRAGMENT_TAG);//from w w w  . j a v  a 2s. co m
            transaction.commit();
        } else {
            LogUtils.wtf(LOG_TAG, "Entered EmlViewerActivity with wrong intent action or type: %s, %s", action,
                    type);
            finish(); // we should not be here. bail out. bail out.
            return;
        }
    } else {
        if (savedInstanceState.containsKey(SAVED_ACCOUNT)) {
            mAccount = savedInstanceState.getParcelable(SAVED_ACCOUNT);
        }
    }

    // Account uri will be null if we launched from outside of the app.
    // So just don't load an account at all.
    if (mAccountUri != null) {
        getLoaderManager().initLoader(ACCOUNT_LOADER, Bundle.EMPTY, mAccountLoadCallbacks);
    }
}

From source file:com.google.android.demos.atom.app.FeedActivity.java

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

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.list_activity);
    ListView listView = (ListView) findViewById(android.R.id.list);
    mEmpty = findViewById(R.id.empty);//from w ww .j  ava 2s.co m
    mLoading = findViewById(R.id.loading);
    mError = findViewById(R.id.error);
    mError.findViewById(R.id.retry).setOnClickListener(this);

    // Loader from last Activity instance may still be loading
    mLoading.setVisibility(View.VISIBLE);
    mEmpty.setVisibility(View.GONE);
    mError.setVisibility(View.GONE);

    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    mAdapter = new FeedAdapter(this);
    mAdapter.registerDataSetObserver(new TitleObserver());
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(this);
    getSupportLoaderManager().initLoader(LOADER_ENTRIES, Bundle.EMPTY, this);
}

From source file:org.androidtitlan.estoesgoogle.service.SyncService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.d(TAG, "onHandleIntent(intent=" + intent.toString() + ")");

    final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER);
    if (receiver != null)
        receiver.send(STATUS_RUNNING, Bundle.EMPTY);
    final SharedPreferences prefs = getSharedPreferences(Prefs.IOSCHED_SYNC, Context.MODE_PRIVATE);

    try {//from ww w  . j  a v a 2 s .c  om
        // Bulk of sync work, performed by executing several fetches from
        // local sources.

        // Load static local data
        mLocalExecutor.execute(R.xml.blocks, new LocalBlocksHandler());
        mLocalExecutor.execute(R.xml.speakers, new LocalSpeakersHandler());
        mLocalExecutor.execute(R.xml.rooms, new LocalRoomsHandler());
        mLocalExecutor.execute(R.xml.tracks, new LocalTracksHandler());
        mLocalExecutor.execute(R.xml.search_suggest, new LocalSearchSuggestHandler());
        mLocalExecutor.execute(R.xml.sessions, new LocalSessionsHandler());

        // Save local parsed version
        prefs.edit().putInt(Prefs.LOCAL_VERSION, VERSION_CURRENT).commit();

    } catch (Exception e) {
        Log.e(TAG, "Problem while syncing", e);

        if (receiver != null) {
            // Pass back error to surface listener
            final Bundle bundle = new Bundle();
            bundle.putString(Intent.EXTRA_TEXT, e.toString());
            receiver.send(STATUS_ERROR, bundle);
        }
    }

    // Announce success to any surface listener
    Log.d(TAG, "sync finished");
    if (receiver != null)
        receiver.send(STATUS_FINISHED, Bundle.EMPTY);
}

From source file:com.stoneapp.ourvlemoodle2.activities.MainActivity.java

/**
 * Create an entry for this application in the system account list, if it isn't already there.
 *
 * @param context Context//from  ww  w  . j  a  va2  s. co  m
 */
public static void CreateSyncAccount(Context context) {
    final String AUTHORITY = BuildConfig.APPLICATION_ID + ".provider";
    // Value below must match the account type specified in res/xml/syncadapter.xml
    final String ACCOUNT_TYPE = BuildConfig.APPLICATION_ID;
    // hours in seconds
    final long SYNC_INTERVAL = SettingsUtils.getSyncInterval(context) * 60L * 60L;

    List<MoodleSiteInfo> sites = MoodleSiteInfo.listAll(MoodleSiteInfo.class);
    String accountName = sites.get(0).getUsername();

    if (TextUtils.isEmpty(accountName))
        accountName = "OurVLE User";

    // Create account, if it's missing. (Either first run, or user has deleted account.)
    Account account = new Account(accountName, ACCOUNT_TYPE);

    AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE);

    /*
     * Add the account and account type, no password or user data
     * If successful, return the Account object, otherwise report an error.
     */
    if (accountManager.addAccountExplicitly(account, null, null)) {
        // Inform the system that this account is eligible for auto sync when the network is up
        ContentResolver.setSyncAutomatically(account, AUTHORITY, true);
        // Recommend a schedule for automatic synchronization. The system may modify this based
        // on other scheduled syncs and network utilization.
        ContentResolver.addPeriodicSync(account, AUTHORITY, Bundle.EMPTY, SYNC_INTERVAL);
    }
}