Java Code Examples for android.os.Bundle

The following are top voted examples for showing how to use android.os.Bundle. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: my-ministry-assistant   File: DatePickerDialogFragment.java View source code Vote up 7 votes
public static DatePickerDialogFragment newInstance(Calendar _date) {
DatePickerDialogFragment frag = new DatePickerDialogFragment();
Bundle args = new Bundle();
      args.putInt(ARG_YEAR, _date.get(Calendar.YEAR));
      args.putInt(ARG_MONTH, _date.get(Calendar.MONTH));
      args.putInt(ARG_DAY, _date.get(Calendar.DAY_OF_MONTH));
      frag.setArguments(args);
      return frag; 
  }
 
Example 2
Project: my-ministry-assistant   File: PublicationTypeDialogFragment.java View source code Vote up 7 votes
public static PublicationTypeDialogFragment newInstance(boolean _showFlow) {
PublicationTypeDialogFragment frag = new PublicationTypeDialogFragment();
Bundle args = new Bundle();
      args.putBoolean(ARG_SHOW_FLOW, _showFlow);
      frag.setArguments(args);
      return frag; 
  }
 
Example 3
Project: nikeplus-fuelband-se-reversed   File: AdvertisementData.java View source code Vote up 6 votes
public static Bundle parse(byte[] scanRecord) {
	Bundle parsed = new Bundle();
	ByteBuffer buffer = ByteBuffer.wrap(scanRecord);
	
	while (true) 
	{
		int i = buffer.remaining() > 0 ? buffer.get() : 0;

		
		if( i == 0 || i > buffer.remaining() )
			break;
		
		int j = buffer.get();
		byte[] arrayOfByte = new byte[i - 1];
		buffer.get(arrayOfByte);
		
		switch (j) {
		default:
			break;
		case -1:
			parsed.putByteArray("COMPANYCODE",Arrays.copyOfRange(arrayOfByte, 0, 2));
			parsed.putByteArray("MANUDATA",Arrays.copyOfRange(arrayOfByte, 2, arrayOfByte.length));
			break;
		case 6:
		case 7:
			parsed.putParcelableArrayList("SERVICES",parseUuids(arrayOfByte));
			break;
		case 9:
			parsed.putString("LOCALNAME", new String(arrayOfByte));
		}
	}
	
	return parsed;
}
 
Example 4
Project: nikeplus-fuelband-se-reversed   File: MainActivity.java View source code Vote up 6 votes
private void dumpDeviceAdvData( Bundle advData ) {
	Set<String> props = advData.keySet();

	for( String prop : props )
	{
		String mess = "  " + prop + " : ";
		
		if( prop.equals("COMPANYCODE") || prop.equals("MANUDATA") )
		{
			byte[] value = advData.getByteArray(prop);
			mess += Utils.bytesToHex(value) + " ( " + new String(value) + " )";
		}
		else if( prop.equals("SERVICES") )
		{
			ArrayList<ParcelUuid> services = advData.getParcelableArrayList(prop);
			for( ParcelUuid uuid : services )
			{
				mess += uuid.toString() + " ";
			}
		}
		else if( prop.equals("LOCALNAME") )
		{
			mess += advData.getString(prop);
		}
		
		Logger.d( mess );
	}
}
 
Example 5
Project: my-ministry-assistant   File: PublicationDialogFragment.java View source code Vote up 6 votes
@Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
adapter = new DialogItemAdapter(getActivity().getApplicationContext());
String name = getActivity().getApplicationContext().getString(R.string.navdrawer_item_publications);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
database = new MinistryService(getActivity());

Bundle args = getArguments();

if(args != null) {
	if(args.containsKey(ARG_PUBLICATION_TYPE_ID))
		litType = args.getInt(ARG_PUBLICATION_TYPE_ID, 0);
	if(args.containsKey(ARG_PUBLICATION_NAME))
		name = args.getString(ARG_PUBLICATION_NAME);
}

adapter.addItem(new NavDrawerMenuItem(getActivity().getApplicationContext().getString(R.string.menu_add_new_with_plus), Helper.getIconResIDByLitTypeID(litType), CREATE_ID));

database.openWritable();
final Cursor cursor = database.fetchLiteratureByType(litType);
   
while(cursor.moveToNext())
	adapter.addItem(new NavDrawerMenuItem(cursor.getString(cursor.getColumnIndex(Literature.NAME)), Helper.getIconResIDByLitTypeID(litType), cursor.getInt(cursor.getColumnIndex(Literature._ID))));
   
   cursor.close();
   database.close();
   
   builder.setTitle(name);
   
   builder.setAdapter(adapter, new OnClickListener() {
	@Override
	public void onClick(DialogInterface dialog, int which) {
  			sListener.literatureDialogFragmentSet(adapter.getItem(which).getID(), adapter.getItem(which).toString(), litType);
	}
});
   
   return builder.create();
  }
 
Example 6
Project: flow-android   File: TouchImageView.java View source code Vote up 6 votes
@Override
public Parcelable onSaveInstanceState() {
    Bundle bundle = new Bundle();
    bundle.putParcelable("instanceState", super.onSaveInstanceState());
    bundle.putFloat("saveScale", normalizedScale);
    bundle.putFloat("matchViewHeight", matchViewHeight);
    bundle.putFloat("matchViewWidth", matchViewWidth);
    bundle.putInt("viewWidth", viewWidth);
    bundle.putInt("viewHeight", viewHeight);
    matrix.getValues(m);
    bundle.putFloatArray("matrix", m);
    return bundle;
}
 
Example 7
Project: my-ministry-assistant   File: PublicationTypeDialogFragment.java View source code Vote up 6 votes
@Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
MinistryService database = new MinistryService(getActivity());
adapter = new DialogItemAdapter(getActivity().getApplicationContext());

Bundle args = getArguments();

if(args != null) {
	if(args.containsKey(ARG_SHOW_FLOW))
		showFlow = args.getBoolean(ARG_SHOW_FLOW, false);
}

database.openWritable();
final Cursor cursor = database.fetchActiveTypesOfLiterature();

while(cursor.moveToNext())
	adapter.addItem(new NavDrawerMenuItem(cursor.getString(cursor.getColumnIndex(LiteratureType.NAME)), Helper.getIconResIDByLitTypeID(cursor.getInt(cursor.getColumnIndex(LiteratureType._ID))), cursor.getInt(cursor.getColumnIndex(LiteratureType._ID))));

cursor.close();
database.close();

builder.setTitle(getActivity().getApplicationContext().getString(R.string.navdrawer_item_publications));

builder.setAdapter(adapter,  new OnClickListener() {
	@Override
	public void onClick(DialogInterface dialog, int which) {
  			sListener.LiteratureTypeDialogFragmentListenerSet(adapter.getItem(which).getID(), adapter.getItem(which).toString());
	}
});

if(showFlow) {
    builder.setNegativeButton(R.string.menu_no_publications, new OnClickListener() {
		@Override
		public void onClick(DialogInterface arg0, int arg1) {
			sListener.LiteratureTypeDialogFragmentListenerSet(MinistryDatabase.CREATE_ID, "");
		}
    });
}
   
   return builder.create();
  }
 
Example 8
Project: Gui2Go   File: EditorActivity.java View source code Vote up 6 votes
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    // Grab info from the intent
    refreshProjectData(true);
    Bundle data = intent.getExtras();
    projectInfo = data.getParcelable("project");
    activityInfo = data.getParcelable("activity");
    this.setTitle(projectInfo.name + " - ");
    if (data.getBoolean("projectLoaderFlag")) {
        // if this activity is loaded from the project loader
        // we need to load the correct layout XML
        LoadXML(projectInfo.name, activityInfo.name);
    }
    if (data.getBoolean("isNewActivity")) {
        saveActivityXML(false);
    }

    // set the correct size
    setScreenSize(activityInfo.screenSize);

    ActionBar actionBar = getActionBar();
    int position = 0;
    for (int i = 0; i < activityList.size(); i++) {
        if (activityList.get(i).name.equals(activityInfo.name)) {
            position = i;
        }
    }
    actionBar.setSelectedNavigationItem(position);
}
 
Example 9
Project: BioWiki   File: SelectCategoriesActivity.java View source code Vote up 6 votes
private void saveAndFinish() {
    Bundle bundle = new Bundle();
    updateSelectedCategoryList();
    bundle.putSerializable("selectedCategories", new ArrayList<String>(mSelectedCategories));
    Intent mIntent = new Intent();
    mIntent.putExtras(bundle);
    setResult(RESULT_OK, mIntent);
    finish();
}
 
Example 10
Project: arduino-android   File: InputController.java View source code Vote up 6 votes
public void openSettings()
{
	Bundle bundle = new Bundle();
	bundle.putLong("index", new Long(index));
	Intent newIntent = new Intent(mHostActivity, SettingsActivity.class);
	newIntent.putExtras(bundle);
	mHostActivity.startActivityForResult(newIntent, 0);
}
 
Example 11
Project: phonegap-geolocation   File: CordovaActivity.java View source code Vote up 6 votes
/**
 * Get boolean property for activity.
 *
 * @param name
 * @param defaultValue
 * @return the boolean value of the named property
 */
public boolean getBooleanProperty(String name, boolean defaultValue) {
    Bundle bundle = this.getIntent().getExtras();
    if (bundle == null) {
        return defaultValue;
    }
    name = name.toLowerCase(Locale.getDefault());
    Boolean p;
    try {
        p = (Boolean) bundle.get(name);
    } catch (ClassCastException e) {
        String s = bundle.get(name).toString();
        if ("true".equals(s)) {
            p = true;
        }
        else {
            p = false;
        }
    }
    if (p == null) {
        return defaultValue;
    }
    return p.booleanValue();
}
 
Example 12
Project: arduino-android   File: SettingsActivity.java View source code Vote up 6 votes
public void onClick(View v) {
    Bundle bundle = this.getIntent().getExtras();
       int index = (int)bundle.getLong("index");
	if (v == saveButton) {
		SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
	    SharedPreferences.Editor editor = settings.edit();
	    
        editor.putString("label"+index, labelField.getText().toString());
	    editor.commit();
	}
}
 
Example 13
Project: BioWiki   File: EditPostSettingsFragment.java View source code Vote up 6 votes
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (data != null || ((requestCode == MediaUtils.RequestCode.ACTIVITY_REQUEST_CODE_TAKE_PHOTO || requestCode == MediaUtils.RequestCode.ACTIVITY_REQUEST_CODE_TAKE_VIDEO))) {
        Bundle extras;

        switch (requestCode) {
            case ACTIVITY_REQUEST_CODE_SELECT_CATEGORIES:
                extras = data.getExtras();
                if (extras != null && extras.containsKey("selectedCategories")) {
                    mCategories = (ArrayList<String>) extras.getSerializable("selectedCategories");
                    populateSelectedCategories();
                }
                break;
        }
    }
}
 
Example 14
Project: proxima   File: ProximityService.java View source code Vote up 6 votes
/**
 * Obtain a list of neighbors from the routing protocol daemon interface and
 * return it back to the client.
 *
 * @param message the REQUEST_NEIGHBORS message received from the client
 */
protected void requestNeighbors(Message message)
{
    Collection<Neighbor> neighbors = mHelper.requestNeighbors();
    ArrayList<String> neighborList = new ArrayList<String>();

    for (Neighbor neighbor : neighbors)
    {
        neighborList.add(neighbor.ipv4Address);
    }

    Bundle data = new Bundle();
    data.putStringArrayList(ProximityManager.EXTRA_NEIGHBOR_LIST,
            neighborList);

    Log.d(TAG, "Sending message RESPONSE_NEIGHBORS");
    replyToMessage(message, ProximityManager.RESPONSE_NEIGHBORS, data);
}
 
Example 15
Project: scope   File: MainActivity.java View source code Vote up 6 votes
@Override
   protected void onSaveInstanceState(Bundle outState)
   {
super.onSaveInstanceState(outState);

// State bundle

Bundle bundle = new Bundle();

// Bright

bundle.putBoolean(BRIGHT, audio.bright);

// Single

bundle.putBoolean(SINGLE, audio.single);

// Polarity

bundle.putBoolean(POLARITY, audio.polarity);

// Timebase

bundle.putInt(TIMEBASE, timebase);

// Storage

bundle.putBoolean(STORAGE, scope.storage);

// Start

bundle.putFloat(START, scope.start);

// Index

bundle.putFloat(INDEX, scope.index);

// Save bundle

outState.putBundle(STATE, bundle);
   }
 
Example 16
Project: ExcusePro   File: MenuBuilder.java View source code Vote up 6 votes
private void dispatchSaveInstanceState(Bundle outState) {
    if (mPresenters.isEmpty()) return;

    SparseArray<Parcelable> presenterStates = new SparseArray<Parcelable>();

    for (WeakReference<MenuPresenter> ref : mPresenters) {
        final MenuPresenter presenter = ref.get();
        if (presenter == null) {
            mPresenters.remove(ref);
        } else {
            final int id = presenter.getId();
            if (id > 0) {
                final Parcelable state = presenter.onSaveInstanceState();
                if (state != null) {
                    presenterStates.put(id, state);
                }
            }
        }
    }

    outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates);
}
 
Example 17
Project: scope   File: MainActivity.java View source code Vote up 6 votes
@Override
   protected void onRestoreInstanceState(Bundle savedInstanceState)
   {
super.onRestoreInstanceState(savedInstanceState);

// Get saved state bundle

Bundle bundle = savedInstanceState.getBundle(STATE);

// Log.d(TAG, "Restore: " + bundle.toString());

// Bright

audio.bright = bundle.getBoolean(BRIGHT, false);

// Single

audio.single = bundle.getBoolean(SINGLE, false);

// Polarity

audio.polarity = bundle.getBoolean(POLARITY, false);

// Timebase

timebase = bundle.getInt(TIMEBASE, DEFAULT_TIMEBASE);
setTimebase(timebase, false);

// Storage

scope.storage = bundle.getBoolean(STORAGE, false);

// Start

scope.start = bundle.getFloat(START, 0);
xscale.start = scope.start;
xscale.postInvalidate();

// Index

scope.index = bundle.getFloat(INDEX, 0);
   }
 
Example 18
Project: ExcusePro   File: MenuBuilder.java View source code Vote up 6 votes
private void dispatchRestoreInstanceState(Bundle state) {
    SparseArray<Parcelable> presenterStates = state.getSparseParcelableArray(PRESENTER_KEY);

    if (presenterStates == null || mPresenters.isEmpty()) return;

    for (WeakReference<MenuPresenter> ref : mPresenters) {
        final MenuPresenter presenter = ref.get();
        if (presenter == null) {
            mPresenters.remove(ref);
        } else {
            final int id = presenter.getId();
            if (id > 0) {
                Parcelable parcel = presenterStates.get(id);
                if (parcel != null) {
                    presenter.onRestoreInstanceState(parcel);
                }
            }
        }
    }
}
 
Example 19
Project: ExcusePro   File: Util.java View source code Vote up 6 votes
/**
 * Parse a URL query and fragment parameters into a key-value bundle.
 *
 * @param url the URL to parse
 * @return a dictionary bundle of keys and values
 */
@Deprecated
public static Bundle parseUrl(String url) {
    // hack to prevent MalformedURLException
    url = url.replace("fbconnect", "http");
    try {
        URL u = new URL(url);
        Bundle b = decodeUrl(u.getQuery());
        b.putAll(decodeUrl(u.getRef()));
        return b;
    } catch (MalformedURLException e) {
        return new Bundle();
    }
}
 
Example 20
Project: dubsar_android   File: WordActivity.java View source code Vote up 6 votes
protected void saveState(Bundle outState) {
	if (mSenses == null) return;
	
	int[] ids = new int[mSenses.getCount()];
	String[] banners = new String[mSenses.getCount()];
	String[] glosses = new String[mSenses.getCount()];
	String[] synonyms = new String[mSenses.getCount()];
	
	int idColumn = mSenses.getColumnIndex(BaseColumns._ID);
	int subtitleColumn = mSenses.getColumnIndex(DubsarContentProvider.SENSE_SUBTITLE);
	int glossColumn = mSenses.getColumnIndex(DubsarContentProvider.SENSE_GLOSS);
	int synonymsColumn = mSenses.getColumnIndex(DubsarContentProvider.SENSE_SYNONYMS_AS_STRING);
	
	for (int j=0; j<mSenses.getCount(); ++j) {
		mSenses.moveToPosition(j);
		
		ids[j] = mSenses.getInt(idColumn);
		banners[j] = mSenses.getString(subtitleColumn);
		glosses[j] = mSenses.getString(glossColumn);
		synonyms[j] = mSenses.getString(synonymsColumn);
	}
	
	outState.putString(DubsarContentProvider.WORD_SUBTITLE, mSubtitle);
	outState.putIntArray(SENSE_IDS, ids);
	outState.putStringArray(SENSE_BANNERS, banners);
	outState.putStringArray(SENSE_GLOSSES, glosses);
	outState.putStringArray(SENSE_SYNONYM_STRINGS, synonyms);
}
 
Example 21
Project: climbers   File: MapsActivity.java View source code Vote up 6 votes
public void onSaveInstanceState(Bundle savedInstanceState)
{
	savedInstanceState.putDouble(StringConstants.LAT, position.latitude);
	savedInstanceState.putDouble(StringConstants.LNG, position.longitude);
	savedInstanceState.putDouble(StringConstants.RADIUS, radius);

	super.onSaveInstanceState(savedInstanceState);
}
 
Example 22
Project: android_packages_apps_AeroControl   File: UndoBarController.java View source code Vote up 6 votes
@Override
public Parcelable onSaveInstanceState() {
    final Bundle outState = new Bundle();
    outState.putCharSequence("undo_message", mUndoMessage);
    outState.putParcelable("undo_token", mUndoToken);
    outState.putParcelable("undo_style", style);
    outState.putInt("visible", getVisibility());
    return outState;
}
 
Example 23
Project: ExcusePro   File: ActionBarSherlockCompat.java View source code Vote up 6 votes
@Override
public void dispatchInvalidateOptionsMenu() {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[dispatchInvalidateOptionsMenu]");

    Bundle savedActionViewStates = null;
    if (mMenu != null) {
        savedActionViewStates = new Bundle();
        mMenu.saveActionViewStates(savedActionViewStates);
        if (savedActionViewStates.size() > 0) {
            mMenuFrozenActionViewState = savedActionViewStates;
        }
        // This will be started again when the panel is prepared.
        mMenu.stopDispatchingItemsChanged();
        mMenu.clear();
    }
    mMenuRefreshContent = true;

    // Prepare the options panel if we have an action bar
    if (wActionBar != null) {
        mMenuIsPrepared = false;
        preparePanel();
    }
}
 
Example 24
Project: hci-2011-2   File: FragmentStatePagerAdapter.java View source code Vote up 6 votes
@Override
public Parcelable saveState() {
    Bundle state = null;
    if (mSavedState.size() > 0) {
        state = new Bundle();
        Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
        mSavedState.toArray(fss);
        state.putParcelableArray("states", fss);
    }
    for (int i=0; i<mFragments.size(); i++) {
        Fragment f = mFragments.get(i);
        if (f != null) {
            if (state == null) {
                state = new Bundle();
            }
            String key = "f" + i;
            mFragmentManager.putFragment(state, key, f);
        }
    }
    return state;
}
 
Example 25
Project: BioWiki   File: CommentsListFragment.java View source code Vote up 6 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    if (outState.isEmpty()) {
        outState.putBoolean("bug_19917_fix", true);
    }
    outState.putBoolean(KEY_AUTO_REFRESHED, mHasAutoRefreshedComments);
    outState.putBoolean(KEY_HAS_CHECKED_DELETED_COMMENTS, mHasCheckedDeletedComments);
    super.onSaveInstanceState(outState);
}
 
Example 26
Project: BambooPlayer   File: MediaPlayer.java View source code Vote up 6 votes
private void updateCacheStatus(int type, int info, long[] segments) {
  if (mEventHandler != null) {
    Message m = mEventHandler.obtainMessage(MEDIA_CACHING_UPDATE);
    Bundle b = m.getData();
    b.putInt(MEDIA_CACHING_TYPE, type);
    b.putInt(MEDIA_CACHING_INFO, info);
    b.putLongArray(MEDIA_CACHING_SEGMENTS, segments);
    mEventHandler.sendMessage(m);
  }
}
 
Example 27
Project: dubsar_android   File: WordActivity.java View source code Vote up 6 votes
protected void retrieveInstanceState(Bundle inState) {
	mSubtitle = inState.getString(DubsarContentProvider.WORD_SUBTITLE);
	if (mSubtitle == null) return;
	
	int[] ids = inState.getIntArray(SENSE_IDS);
	String[] banners = inState.getStringArray(SENSE_BANNERS);
	String[] glosses = inState.getStringArray(SENSE_GLOSSES);
	String[] synonyms = inState.getStringArray(SENSE_SYNONYM_STRINGS);
	
	String[] columns = { BaseColumns._ID, 
			DubsarContentProvider.SENSE_SUBTITLE,
			DubsarContentProvider.SENSE_GLOSS, 
			DubsarContentProvider.SENSE_SYNONYMS_AS_STRING };
	MatrixCursor cursor = new MatrixCursor(columns, ids.length);
	MatrixCursor.RowBuilder builder;
	
	for (int j=0; j<ids.length; ++j) {
		builder = cursor.newRow();
		builder.add(Integer.valueOf(ids[j]));
		builder.add(banners[j]);
		builder.add(glosses[j]);
		builder.add(synonyms[j]);
	}
	
	mSenses = cursor;
}
 
Example 28
Project: Pure-File-Manager   File: BrowserFragment.java View source code Vote up 6 votes
public void restoreManualState(final Bundle state) {
    if (state != null) {
        state.setClassLoader(BrowserFragment.class.getClassLoader());
        final BrowserFragment.SavedState savedState = state.getParcelable(STATE_BROWSER);
        if (savedState != null) {
            if (savedState.mBrowserState != null) {
                if (mBrowser != null) {
                    mBrowser.restoreState(savedState.mBrowserState);
                } else {
                    mBrowserInitialState = savedState.mBrowserState;
                }
            }
            mPrevId = savedState.mPrevId;
        }
    }
}
 
Example 29
Project: android_packages_apps_AeroControl   File: UndoBarController.java View source code Vote up 6 votes
@Override
public void onRestoreInstanceState(final Parcelable state) {
    if (state instanceof Bundle) {
        final Bundle bundle = (Bundle) state;
        mUndoMessage = bundle.getCharSequence("undo_message");
        mUndoToken = bundle.getParcelable("undo_token");
        style = bundle.getParcelable("undo_style");
        if (bundle.getInt("visible") == View.VISIBLE)
            showUndoBar(true, mUndoMessage, mUndoToken);
        return;
    }
    super.onRestoreInstanceState(state);
}
 
Example 30
Project: BioWiki   File: NotificationsActivity.java View source code Vote up 6 votes
@Override
public void onSaveInstanceState(Bundle outState) {
    if (outState.isEmpty()) {
        outState.putBoolean("bug_19917_fix", true);
    }
    outState.putBoolean(KEY_INITIAL_UPDATE, mHasPerformedInitialUpdate);
    outState.remove(NOTE_ID_EXTRA);
    super.onSaveInstanceState(outState);
}
 
Example 31
Project: hci-2011-2   File: FragmentStatePagerAdapter.java View source code Vote up 6 votes
@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle)state;
        bundle.setClassLoader(loader);
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int i=0; i<fss.length; i++) {
                mSavedState.add((Fragment.SavedState)fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key: keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}
 
Example 32
Project: newFunf   File: GravitySensorProbeTest.java View source code Vote up 6 votes
public void testData() throws InterruptedException {
		Bundle params = new Bundle();
		params.putLong(Parameter.Builtin.DURATION.name, 3L);
		params.putLong(Parameter.Builtin.PERIOD.name, 10L);
		startProbe(params);
		for (int i=0; i<3; i++) {
			Bundle data = getData(10);
			assertTrue(data.containsKey("SENSOR"));
			assertTrue(data.containsKey("EVENT_TIMESTAMP"));
			assertTrue(data.containsKey("ACCURACY"));
			assertTrue(data.containsKey("X"));
			assertTrue(data.containsKey("Y"));
			assertTrue(data.containsKey("Z"));
			assertTrue(data.containsKey("TIMESTAMP"));
			long[] eventTimestamp = data.getLongArray("EVENT_TIMESTAMP");
			int[] accuracy = data.getIntArray("ACCURACY");
			float[] x = data.getFloatArray("X");
			float[] y = data.getFloatArray("Y");
			float[] z = data.getFloatArray("Z");
			int numEvents = eventTimestamp.length;
			assertEquals(numEvents, accuracy.length);
			assertEquals(numEvents, x.length);
			assertEquals(numEvents, y.length);
			assertEquals(numEvents, z.length);
//			System.out.println("@" + data.getLong("TIMESTAMP") + " - " +
//					"X:" + data.getFloat("X") +
//					"Y:" + data.getFloat("Y") +
//					"Z:" + data.getFloat("Z")
//			);
		}
	}
 
Example 33
Project: SliderBar   File: SliderFragment.java View source code Vote up 6 votes
@Override
public void onSaveInstanceState(Bundle outState) {
	// Save the slider state on rotate
	super.onSaveInstanceState(outState);
	float[] sliderValues = new float[sliders.size()];
	for (int i = 0; i < sliders.size(); i++) {
		sliderValues[i] = sliders.get(i).getSliderPosition();
	}
	outState.putFloatArray("sliderValues", sliderValues);
	outState.putIntegerArrayList("actionQueue",
			sliderLayoutListener.getActionQueue());
}
 
Example 34
Project: dubsar_android   File: SynsetActivity.java View source code Vote up 6 votes
protected void saveState(Bundle outState) {
	if (mResult == null) return;
	
	if (mAdapter != null) {
		outState.putBooleanArray(EXPANDED, mAdapter.getExpanded());
	}
	outState.putString(DubsarContentProvider.SYNSET_SUBTITLE, mSubtitle);
	outState.putString(DubsarContentProvider.SYNSET_GLOSS, mGloss);
	outState.putString(DubsarContentProvider.SYNSET_POS, mPos);
	
	bundleSynonyms(outState);
	bundleSamples(outState);
	bundlePointers(outState);
}
 
Example 35
Project: property-db   File: SyncStorageEngine.java View source code Vote up 6 votes
static private byte[] flattenBundle(Bundle bundle) {
    byte[] flatData = null;
    Parcel parcel = Parcel.obtain();
    try {
        bundle.writeToParcel(parcel, 0);
        flatData = parcel.marshall();
    } finally {
        parcel.recycle();
    }
    return flatData;
}
 
Example 36
Project: property-db   File: AppWidgetServiceImpl.java View source code Vote up 6 votes
public Bundle getAppWidgetOptions(int appWidgetId) {
    synchronized (mAppWidgetIds) {
        ensureStateLoadedLocked();
        AppWidgetId id = lookupAppWidgetIdLocked(appWidgetId);
        if (id != null && id.options != null) {
            return cloneIfLocalBinder(id.options);
        } else {
            return Bundle.EMPTY;
        }
    }
}
 
Example 37
Project: flow-android   File: TouchImageView.java View source code Vote up 6 votes
@Override
public void onRestoreInstanceState(Parcelable state) {
    if (state instanceof Bundle) {
        Bundle bundle = (Bundle) state;
        normalizedScale = bundle.getFloat("saveScale");
        m = bundle.getFloatArray("matrix");
        prevMatrix.setValues(m);
        prevMatchViewHeight = bundle.getFloat("matchViewHeight");
        prevMatchViewWidth = bundle.getFloat("matchViewWidth");
        prevViewHeight = bundle.getInt("viewHeight");
        prevViewWidth = bundle.getInt("viewWidth");
        super.onRestoreInstanceState(bundle.getParcelable("instanceState"));
        return;
    }

    super.onRestoreInstanceState(state);
}
 
Example 38
Project: afwall   File: BundleScrubber.java View source code Vote up 6 votes
/**
 * Scrubs Bundles for private serializable subclasses in the extras. If the Bundle's extras contain a
 * private serializable subclass, the Bundle is cleared. If the Bundle is null, has no extras, or the
 * extras do not contain a private serializable subclass, the Bundle is not mutated.
 * 
 * @param bundle [email protected] Bundle} to scrub. This parameter may be mutated if scrubbing is necessary. This
 *            parameter may be null.
 * @return true if the Bundle was scrubbed, false if the Bundle was not modified.
 */
public static boolean scrub(final Bundle bundle)
{
    if (null == bundle)
    {
        return false;
    }

    /*
     * Note: This is a hack to work around a private serializable classloader attack
     */
    try
    {
        // if a private serializable exists, this will throw an exception
        bundle.containsKey(null);
    }
    catch (final Exception e)
    {
        bundle.clear();
        return true;
    }

    return false;
}
 
Example 39
Project: newFunf   File: BundleUtil.java View source code Vote up 6 votes
/**
 * Convenience function for putting the object form of primitives into a Bundle
 * @param bundle
 * @param key
 * @param value Must be Boolean, Float, Integer, Long, or String
 * @throws UnstorableTypeException
 */
public static void putInBundle(Bundle bundle, String key, Object value) throws UnstorableTypeException {
	Class<?> valueClass = value.getClass();
	if (Boolean.class.isAssignableFrom(valueClass)) {
		bundle.putBoolean(key, ((Boolean)value).booleanValue());
	} else if (Short.class.isAssignableFrom(valueClass)) {
			bundle.putShort(key, ((Short) value).shortValue());
	} else if (Integer.class.isAssignableFrom(valueClass)) {
		bundle.putInt(key, ((Integer) value).intValue());
	} else if (Long.class.isAssignableFrom(valueClass)) {
		bundle.putLong(key, ((Long) value).longValue());
	} else if (Float.class.isAssignableFrom(valueClass)) {
		bundle.putFloat(key, ((Float) value).floatValue());
	} else if (Double.class.isAssignableFrom(valueClass)) {
		bundle.putDouble(key, ((Double) value).doubleValue());
	}  else if (String.class.isAssignableFrom(valueClass)) {
		bundle.putString(key, ((String) value));
	} else {
		throw new UnstorableTypeException(valueClass);
	}
}
 
Example 40
Project: property-db   File: Intent.java View source code Vote up 6 votes
/**
 * Add extended data to the intent.  The name must include a package
 * prefix, for example the app com.android.contacts would use names
 * like "com.android.contacts.ShowAll".
 *
 * @param name The name of the extra data, with package prefix.
 * @param value The byte data value.
 *
 * @return Returns the same Intent object, for chaining multiple calls
 * into a single statement.
 *
 * @see #putExtras
 * @see #removeExtra
 * @see #getByteExtra(String, byte)
 */
public Intent putExtra(String name, byte value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putByte(name, value);
    return this;
}
 
Example 41
Project: SliderBar   File: SliderFragment.java View source code Vote up 6 votes
@Override
public void onActivityCreated(Bundle savedInstanceState) {
	super.onActivityCreated(savedInstanceState);

	// initialize all sliders definded in the layout
	sliders = new ArrayList<SliderBar>();
	// Listener that can handle all actions from the sliders in the layout
	sliderLayoutListener = new SliderLayoutListener(sliders, this);
	LinearLayout layout = (LinearLayout) getActivity().findViewById(
			R.id.slider_layout);

	int sliderIndex = 0; // index of the slider used to restore its state
	Random rand = new Random();
	for (int i = 0; i < layout.getChildCount(); i++) {
		View v = layout.getChildAt(i);
		Class c = v.getClass();
		if (c == SliderBar.class) {
			// Setup the slider and add it to the List of all SliderBars
			SliderBar slider;
			slider = (SliderBar) v;
			slider.setSliderListener(sliderLayoutListener);
			slider.setMinMaxPos(1, 7);
			slider.setSliderBorderOffset(10);
			if (savedInstanceState != null) {
				// restore slider position
				slider.setSliderPosition(savedInstanceState
						.getFloatArray("sliderValues")[sliderIndex]);
			} else {
				slider.setInitialPosition(rand.nextInt(6)); // set random
															// initial
															// position
			}
			sliders.add(slider);
			sliderIndex++;
		}
	}

	if (savedInstanceState != null) {
		ArrayList<Integer> actionQueue = savedInstanceState
				.getIntegerArrayList("actionQueue");
		if (actionQueue.size() > 0) {
			// send request that has not yet been sent
			SliderActivity sa = (SliderActivity) this.getActivity();
			sa.onSliderChanged(sliders, actionQueue);
		}
	}
}
 
Example 42
Project: R.tools   File: QualifierListFragment.java View source code Vote up 6 votes
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    String[] qualifierNames = getResources().getStringArray(R.array.qualifiers);
    boolean[] checkedQualifiers;
    int position = 0;
    // Restore the previously serialized activated item position.
    if (savedInstanceState != null && savedInstanceState.containsKey(PARAM_SELECTED_BOOLEAN_SPARSE)) {
        checkedQualifiers = savedInstanceState.getBooleanArray(PARAM_SELECTED_BOOLEAN_SPARSE);
        position = savedInstanceState.getInt(PARAM_SELECTED_ITEM, 0);
    } else {
        checkedQualifiers = new boolean[qualifierNames.length];
    }

    mAdapter = new QualifierAdapter(getContext(), checkedQualifiers, this);
    mAdapter.setSelectedPosition(position);
    mAdapter.setHasStableIds(true);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    mRecyclerView.setAdapter(mAdapter);
}
 
Example 43
Project: property-db   File: ActivityManagerService.java View source code Vote up 6 votes
public final void activityStopped(IBinder token, Bundle icicle, Bitmap thumbnail,
        CharSequence description) {
    if (localLOGV) Slog.v(
        TAG, "Activity stopped: token=" + token);

    // Refuse possible leaked file descriptors
    if (icicle != null && icicle.hasFileDescriptors()) {
        throw new IllegalArgumentException("File descriptors passed in Bundle");
    }

    ActivityRecord r = null;

    final long origId = Binder.clearCallingIdentity();

    synchronized (this) {
        r = mMainStack.isInStackLocked(token);
        if (r != null) {
            r.stack.activityStoppedLocked(r, icicle, thumbnail, description);
        }
    }

    if (r != null) {
        sendPendingThumbnail(r, null, null, null, false);
    }

    trimApplications();

    Binder.restoreCallingIdentity(origId);
}
 
Example 44
Project: property-db   File: Intent.java View source code Vote up 6 votes
/**
 * Add extended data to the intent.  The name must include a package
 * prefix, for example the app com.android.contacts would use names
 * like "com.android.contacts.ShowAll".
 *
 * @param name The name of the extra data, with package prefix.
 * @param value The double array data value.
 *
 * @return Returns the same Intent object, for chaining multiple calls
 * into a single statement.
 *
 * @see #putExtras
 * @see #removeExtra
 * @see #getDoubleArrayExtra(String)
 */
public Intent putExtra(String name, double[] value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putDoubleArray(name, value);
    return this;
}
 
Example 45
Project: AndroidLockpattern   File: LockPatternActivity.java View source code Vote up 6 votes
/**
 * Finishes activity with [email protected] Activity#RESULT_OK}.
 * 
 * @param pattern
 *            the pattern, if this is in mode creating pattern. In any
 *            cases, it can be set to [email protected] null}.
 */
private void finishWithResultOk(char[] pattern) {
    if (ACTION_CREATE_PATTERN.equals(getIntent().getAction()))
        mIntentResult.putExtra(EXTRA_PATTERN, pattern);
    else {
        /*
         * If the user was "logging in", minimum try count can not be zero.
         */
        mIntentResult.putExtra(EXTRA_RETRY_COUNT, mRetryCount + 1);
    }

    setResult(RESULT_OK, mIntentResult);

    /*
     * ResultReceiver
     */
    ResultReceiver receiver = getIntent().getParcelableExtra(
            EXTRA_RESULT_RECEIVER);
    if (receiver != null) {
        Bundle bundle = new Bundle();
        if (ACTION_CREATE_PATTERN.equals(getIntent().getAction()))
            bundle.putCharArray(EXTRA_PATTERN, pattern);
        else {
            /*
             * If the user was "logging in", minimum try count can not be
             * zero.
             */
            bundle.putInt(EXTRA_RETRY_COUNT, mRetryCount + 1);
        }
        receiver.send(RESULT_OK, bundle);
    }

    /*
     * PendingIntent
     */
    PendingIntent pi = getIntent().getParcelableExtra(
            EXTRA_PENDING_INTENT_OK);
    if (pi != null) {
        try {
            pi.send(this, RESULT_OK, mIntentResult);
        } catch (Throwable t) {
            Log.e(CLASSNAME, "Error sending PendingIntent: " + pi, t);
        }
    }

    finish();
}
 
Example 46
Project: property-db   File: Intent.java View source code Vote up 6 votes
/**
 * Add extended data to the intent.  The name must include a package
 * prefix, for example the app com.android.contacts would use names
 * like "com.android.contacts.ShowAll".
 *
 * @param name The name of the extra data, with package prefix.
 * @param value The short array data value.
 *
 * @return Returns the same Intent object, for chaining multiple calls
 * into a single statement.
 *
 * @see #putExtras
 * @see #removeExtra
 * @see #getShortArrayExtra(String)
 */
public Intent putExtra(String name, short[] value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putShortArray(name, value);
    return this;
}
 
Example 47
Project: property-db   File: Intent.java View source code Vote up 6 votes
/**
 * Add extended data to the intent.  The name must include a package
 * prefix, for example the app com.android.contacts would use names
 * like "com.android.contacts.ShowAll".
 *
 * @param name The name of the extra data, with package prefix.
 * @param value The char data value.
 *
 * @return Returns the same Intent object, for chaining multiple calls
 * into a single statement.
 *
 * @see #putExtras
 * @see #removeExtra
 * @see #getCharExtra(String, char)
 */
public Intent putExtra(String name, char value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putChar(name, value);
    return this;
}
 
Example 48
Project: property-db   File: Intent.java View source code Vote up 6 votes
/**
 * Add extended data to the intent.  The name must include a package
 * prefix, for example the app com.android.contacts would use names
 * like "com.android.contacts.ShowAll".
 *
 * @param name The name of the extra data, with package prefix.
 * @param value The IBinder data value.
 *
 * @return Returns the same Intent object, for chaining multiple calls
 * into a single statement.
 *
 * @see #putExtras
 * @see #removeExtra
 * @see #getIBinderExtra(String)
 *
 * @deprecated
 * @hide
 */
@Deprecated
public Intent putExtra(String name, IBinder value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putIBinder(name, value);
    return this;
}
 
Example 49
Project: Android-MapForgeFragment   File: MapFragment.java View source code Vote up 6 votes
@Override
public MapView onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	MapView mapView = new MapView(getActivity(), mMapViewMode);
	if (savedInstanceState != null) {
		final int latitude = savedInstanceState.getInt(KEY_LATITUDE_E6, Integer.MIN_VALUE);
		final int longitude = savedInstanceState.getInt(KEY_LONGITUDE_E6, Integer.MIN_VALUE);
		final byte zoom = savedInstanceState.getByte(KEY_ZOOM_LEVEL, Byte.MIN_VALUE);
		final String mapFile = savedInstanceState.getString(KEY_MAP_FILE);
		
		if ((mapFile != null) && !mapView.getMapViewMode().requiresInternetConnection()) {
			mapView.setMapFileFromParcel(mapFile);
		}
		
		if ((latitude != Integer.MIN_VALUE) && (longitude != Integer.MIN_VALUE) && (zoom != Byte.MIN_VALUE)) {
			mapView.setCenterAndZoom(new GeoPoint(latitude, longitude), zoom);
		}
	}
	
	return mapView;
}
 
Example 50
Project: AcDisplay   File: Extractor.java View source code Vote up 6 votes
/**
 * Loads all possible texts from given [email protected] Notification#extras extras}.
 *
 * @param extras extras to load from
 */
@SuppressLint("InlinedApi")
private void loadFromExtras(@NonNull OpenNotification n, @NonNull Bundle extras) {
    n.titleBigText = extras.getCharSequence(Notification.EXTRA_TITLE_BIG);
    n.titleText = extras.getCharSequence(Notification.EXTRA_TITLE);
    n.infoText = extras.getCharSequence(Notification.EXTRA_INFO_TEXT);
    n.subText = extras.getCharSequence(Notification.EXTRA_SUB_TEXT);
    n.summaryText = extras.getCharSequence(Notification.EXTRA_SUMMARY_TEXT);
    n.messageBigText = removeColorSpans(extras.getCharSequence(Notification.EXTRA_BIG_TEXT));
    n.messageText = removeColorSpans(extras.getCharSequence(Notification.EXTRA_TEXT));

    CharSequence[] lines = extras.getCharSequenceArray(Notification.EXTRA_TEXT_LINES);
    n.messageTextLines = doIt(lines);
}
 
Example 51
Project: WS171-development   File: MyRssReader.java View source code Vote up 6 votes
@Override
protected void onSaveInstanceState(Bundle outState){
    int index = mRssList.getSelectedItemIndex();
    if(index > -1){
        outState.putInteger("lastIndexItem", index);
    }
}
 
Example 52
Project: property-db   File: Intent.java View source code Vote up 6 votes
/**
 * Add extended data to the intent.  The name must include a package
 * prefix, for example the app com.android.contacts would use names
 * like "com.android.contacts.ShowAll".
 *
 * @param name The name of the extra data, with package prefix.
 * @param value The CharSequence array data value.
 *
 * @return Returns the same Intent object, for chaining multiple calls
 * into a single statement.
 *
 * @see #putExtras
 * @see #removeExtra
 * @see #getCharSequenceArrayExtra(String)
 */
public Intent putExtra(String name, CharSequence[] value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putCharSequenceArray(name, value);
    return this;
}
 
Example 53
Project: O2OMobile_Android   File: ErrorDialogFragmentFactory.java View source code Vote up 6 votes
/**
 * Prepares the fragment's arguments and creates the fragment. May be overridden to provide custom error fragments.
 * 
 * @param argumentsForErrorDialog
 * @param finishAfterDialog
 */
protected T prepareErrorFragment(ThrowableFailureEvent event, boolean finishAfterDialog,
        Bundle argumentsForErrorDialog) {
    if (event.isSuppressErrorUi()) {
        // Show nothing by default
        return null;
    }
    Bundle bundle;
    if (argumentsForErrorDialog != null) {
        bundle = (Bundle) argumentsForErrorDialog.clone();
    } else {
        bundle = new Bundle();
    }

    if (!bundle.containsKey(ErrorDialogManager.KEY_TITLE)) {
        String title = getTitleFor(event, bundle);
        bundle.putString(ErrorDialogManager.KEY_TITLE, title);
    }
    if (!bundle.containsKey(ErrorDialogManager.KEY_MESSAGE)) {
        String message = getMessageFor(event, bundle);
        bundle.putString(ErrorDialogManager.KEY_MESSAGE, message);
    }
    if (!bundle.containsKey(ErrorDialogManager.KEY_FINISH_AFTER_DIALOG)) {
        bundle.putBoolean(ErrorDialogManager.KEY_FINISH_AFTER_DIALOG, finishAfterDialog);
    }
    if (!bundle.containsKey(ErrorDialogManager.KEY_EVENT_TYPE_ON_CLOSE)
            && config.defaultEventTypeOnDialogClosed != null) {
        bundle.putSerializable(ErrorDialogManager.KEY_EVENT_TYPE_ON_CLOSE, config.defaultEventTypeOnDialogClosed);
    }
    if (!bundle.containsKey(ErrorDialogManager.KEY_ICON_ID) && config.defaultDialogIconId != 0) {
        bundle.putInt(ErrorDialogManager.KEY_ICON_ID, config.defaultDialogIconId);
    }
    return createErrorFragment(event, bundle);
}
 
Example 54
Project: OpenCVTour   File: EditTourItemActivity.java View source code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	Log.d(TAG, "onCreate called");
	super.onCreate(savedInstanceState);

	setContentView(R.layout.activity_edit_tour_item);

	/// Find the TourItem we're editing, and display its current values.
	Bundle bundle = getIntent().getExtras();
	short position_in_tour =  bundle.getShort("position");
	_tour_item = Tour.getCurrentTour().getTourItems().get(position_in_tour);

	/// GridView of images in the TourItem
	ExpandableHeightGridView gridview = (ExpandableHeightGridView) findViewById(R.id.gridview);
	gridview.setAdapter(new TourItemImageAdapter(_tour_item));
	gridview.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL);
	gridview.setMultiChoiceModeListener(this);
	gridview.setExpanded(true);

	((EditText) findViewById(R.id.edit_tour_item_name)).setText(_tour_item.getName());
	((EditText) findViewById(R.id.edit_tour_item_description)).setText(_tour_item.getDescription());
	((EditText) findViewById(R.id.edit_tour_item_directions)).setText(_tour_item.getDirections());

	if(_tour_item.getLocation() != null) {
		((TextView) findViewById(R.id.tour_item_location)).setText("location: " + _tour_item.getLocation().getLatitude() + ", " + _tour_item.getLocation().getLongitude() + ", accuracy: " + _tour_item.getLocation().getAccuracy() + " meters");
	}

	findViewById(R.id.image_picker).setOnClickListener(this);
	findViewById(R.id.get_current_gps_location).setOnClickListener(this);
	findViewById(R.id.record_audio).setOnClickListener(this);
	findViewById(R.id.play_audio).setOnClickListener(this);

	if(_tour_item.hasAudioFile())
		findViewById(R.id.play_audio).setVisibility(View.VISIBLE);
	else
		findViewById(R.id.play_audio).setVisibility(View.INVISIBLE);

	bindLocationService();

	/// Load stuff from a previous instance
	if(savedInstanceState != null) {
		if (savedInstanceState.containsKey("_photo_uri")) {
			_photo_uri = Uri.parse(savedInstanceState.getString("_photo_uri"));
		}
		if(savedInstanceState.containsKey("_images_selected")) {
			_images_selected = savedInstanceState.getStringArrayList("_images_selected");
		}
	}
}
 
Example 55
Project: property-db   File: SettingsProvider.java View source code Vote up 6 votes
/**
 * Atomic cache population, conditional on size of value and if
 * we lost a race.
 *
 * @returns a Bundle to send back to the client from call(), even
 *     if we lost the race.
 */
public Bundle putIfAbsent(String key, String value) {
    Bundle bundle = (value == null) ? NULL_SETTING : Bundle.forPair("value", value);
    if (value == null || value.length() <= MAX_CACHE_ENTRY_SIZE) {
        synchronized (this) {
            if (get(key) == null) {
                put(key, bundle);
            }
        }
    }
    return bundle;
}
 
Example 56
Project: Mandelbrot-Maps-on-Android   File: FractalActivity.java View source code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);  
	
	requestWindowFeature(Window.FEATURE_NO_TITLE);
	getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);   
	Thread.currentThread().setPriority(Thread.MAX_PRIORITY);      
	
	// If first time launch, show the tutorial/intro
	SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
	if(prefs.getBoolean(FIRST_TIME_KEY, true)) showIntro();
  
  	Bundle bundle = getIntent().getExtras();
  
  	mjLocation = new MandelbrotJuliaLocation();
  	double[] juliaParams = mjLocation.defaultJuliaParams;
  	double[] juliaGraphArea = mjLocation.defaultJuliaGraphArea;
 
  	relativeLayout = new RelativeLayout(this);
     
  	//Extract features from bundle, if there is one
	try {     
		fractalType = FractalType.valueOf(bundle.getString("FractalType"));
		littleMandelbrotLocation = bundle.getDoubleArray("LittleMandelbrotLocation");
		showLittleAtStart = bundle.getBoolean("ShowLittleAtStart");
	}
	catch (NullPointerException npe) {}
	
	if (fractalType == FractalType.MANDELBROT) {
		fractalView = new MandelbrotFractalView(this, FractalViewSize.LARGE);
	}
	else if (fractalType == FractalType.JULIA) {
		fractalView = new JuliaFractalView(this, FractalViewSize.LARGE);
		juliaParams = bundle.getDoubleArray("JuliaParams");
		juliaGraphArea = bundle.getDoubleArray("JuliaGraphArea");
	}
	else {
		fractalView = new CubicMandelbrotFractalView(this, FractalViewSize.LARGE);
	}
	
	LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
	relativeLayout.addView(fractalView, lp);
	setContentView(relativeLayout);
	
	mjLocation = new MandelbrotJuliaLocation(juliaGraphArea, juliaParams);
	fractalView.loadLocation(mjLocation);
	
	gestureDetector = new ScaleGestureDetector(this, this);
}
 
Example 57
Project: property-db   File: LoadedApk.java View source code Vote up 6 votes
public void performReceive(Intent intent, int resultCode, String data,
        Bundle extras, boolean ordered, boolean sticky, int sendingUser) {
    LoadedApk.ReceiverDispatcher rd = mDispatcher.get();
    if (ActivityThread.DEBUG_BROADCAST) {
        int seq = intent.getIntExtra("seq", -1);
        Slog.i(ActivityThread.TAG, "Receiving broadcast " + intent.getAction() + " seq=" + seq
                + " to " + (rd != null ? rd.mReceiver : null));
    }
    if (rd != null) {
        rd.performReceive(intent, resultCode, data, extras,
                ordered, sticky, sendingUser);
    } else {
        // The activity manager dispatched a broadcast to a registered
        // receiver in this process, but before it could be delivered the
        // receiver was unregistered.  Acknowledge the broadcast on its
        // behalf so that the system's broadcast sequence can continue.
        if (ActivityThread.DEBUG_BROADCAST) Slog.i(ActivityThread.TAG,
                "Finishing broadcast to unregistered receiver");
        IActivityManager mgr = ActivityManagerNative.getDefault();
        try {
            if (extras != null) {
                extras.setAllowFds(false);
            }
            mgr.finishReceiver(this, resultCode, data, extras, false);
        } catch (RemoteException e) {
            Slog.w(ActivityThread.TAG, "Couldn't finish broadcast to unregistered receiver");
        }
    }
}
 
Example 58
Project: property-db   File: Intent.java View source code Vote up 6 votes
/**
 * Add extended data to the intent.  The name must include a package
 * prefix, for example the app com.android.contacts would use names
 * like "com.android.contacts.ShowAll".
 *
 * @param name The name of the extra data, with package prefix.
 * @param value The ArrayList<CharSequence> data value.
 *
 * @return Returns the same Intent object, for chaining multiple calls
 * into a single statement.
 *
 * @see #putExtras
 * @see #removeExtra
 * @see #getCharSequenceArrayListExtra(String)
 */
public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
    if (mExtras == null) {
        mExtras = new Bundle();
    }
    mExtras.putCharSequenceArrayList(name, value);
    return this;
}
 
Example 59
Project: cwac-mediarouter   File: RemotePlaybackClient.java View source code Vote up 6 votes
private static String bundleToString(Bundle bundle) {
    if (bundle != null) {
        bundle.size(); // force bundle to be unparcelled
        return bundle.toString();
    }
    return "null";
}
 
Example 60
Project: proxima   File: Channel.java View source code Vote up 5 votes
/**
 *
 * @see android.os.Handler#handleMessage(android.os.Message)
 */
@Override
public void handleMessage(Message message)
{
    Object listener = mChannel.get().getListener(message.arg2);

    switch (message.what)
    {
        case Channel.CHANNEL_DISCONNECTED:
            Log.d(TAG, "Received CHANNEL_DISCONNECTED");
            if (mChannelListener != null)
            {
                mChannelListener.onChannelDisconnected();
                mChannelListener = null;
            }
            break;

        case ProximityManager.DISCOVER_NEIGHBORS_FAILED:
            Log.d(TAG, "Received DISCOVER_NEIGHBORS_FAILED");
            if (listener != null)
            {
                ((ActionListener) listener).onFailure(message.arg1);
            }
            break;

        case ProximityManager.DISCOVER_NEIGHBORS_SUCCEEDED:
            Log.d(TAG, "Received DISCOVER_NEIGHBORS_SUCCEEDED");
            if (listener != null)
            {
                ((ActionListener) listener).onSuccess();
            }
            break;

        case ProximityManager.RESPONSE_NEIGHBORS:
            Log.d(TAG, "Received RESPONSE_NEIGHBORS");
            Bundle bundle = message.getData();
            ArrayList<String> neighbors = bundle
                    .getStringArrayList(ProximityManager.EXTRA_NEIGHBOR_LIST);

            // Call the listener
            if (listener != null)
            {
                ((NeighborListListener) listener)
                        .onNeighborsAvailable(neighbors);
            }
            break;

        default:
            super.handleMessage(message);
    }
}
 
Example 61
Project: climbers   File: MapsActivity.java View source code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_maps);
	getActionBar().setDisplayHomeAsUpEnabled(true);

	mMap = ((MapFragment) getFragmentManager().findFragmentById(
			R.id.map)).getMap();
	seekBar = (SeekBar) findViewById(R.id.seekBarRadius);

	mMap.setMyLocationEnabled(true);

	seekBarListener = new MySeekBarChangeListener();
	seekBar.setOnSeekBarChangeListener(seekBarListener);

	MapClickListener clickListener = new MapClickListener(mMap, seekBarListener, this);
	mMap.setOnMapClickListener(clickListener);

	Criteria criteria = new Criteria();
	LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
	String provider = locationManager.getBestProvider(criteria, false);

	if(savedInstanceState != null)
	{
		position = new LatLng(savedInstanceState.getDouble(StringConstants.LAT), savedInstanceState.getDouble(StringConstants.LNG));
		radius = savedInstanceState.getDouble(StringConstants.RADIUS);
	}
	else
	{
		Location location = locationManager.getLastKnownLocation(provider);
		double lat =  location.getLatitude();
		double lng = location.getLongitude();
		Intent intent = getIntent();
		lat = intent.getDoubleExtra(StringConstants.LAT, lat);
		lng = intent.getDoubleExtra(StringConstants.LNG, lng);
		radius = intent.getDoubleExtra(StringConstants.RADIUS, 1000);
		position = new LatLng(lat, lng);
	}

	CircleOptions circleOptions = new CircleOptions()
	.center(position)
	.radius(radius)
	.strokeWidth(2).strokeColor(Color.BLUE)
	.fillColor(Color.parseColor("#500084d3"));

	Circle circle = mMap.addCircle(circleOptions);
	seekBarListener.setCircle(circle);

	CameraPosition cameraPosition = new CameraPosition.Builder()
	.target(position)
	.zoom(11)
	.build();
	mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}