Example usage for android.os Bundle getSerializable

List of usage examples for android.os Bundle getSerializable

Introduction

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

Prototype

@Override
@Nullable
public Serializable getSerializable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.karmick.android.citizenalert.alarm.AlarmAddActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.alarm_add);/*from  w  ww . ja  v a 2s  .c om*/

    actionBar();

    initViews();

    Bundle bundle = getIntent().getExtras();
    if (bundle != null && bundle.containsKey("alarm")) {
        setMathAlarm((Alarm) bundle.getSerializable("alarm"));
    } else {
        setMathAlarm(new Alarm());
    }

    fillAlarmData();

    eventCalls();
}

From source file:alba_manager.albamanager.Util.colorpicker.ColorPickerDialog.java

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

    if (getArguments() != null) {
        mTitleResId = getArguments().getInt(KEY_TITLE_ID);
        mColumns = getArguments().getInt(KEY_COLUMNS);
        mSize = getArguments().getInt(KEY_SIZE);
    }// w w  w.  j  a v  a 2 s . co  m

    if (savedInstanceState != null) {
        mColors = savedInstanceState.getIntArray(KEY_COLORS);
        mSelectedColor = (Integer) savedInstanceState.getSerializable(KEY_SELECTED_COLOR);
    }

}

From source file:com.teddoll.movies.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    favorites = Favorites.getInstance(this);
    this.progress = (ProgressBar) findViewById(R.id.progress);
    this.movieProvider = MovieProvider.getInstance(HttpClientProvider.getInstance(this).getHttpClient());
    if (savedInstanceState == null) {
        sort = Sort.POP;/* www. j av  a2  s  .c  o m*/
    } else {
        sort = (Sort) savedInstanceState.getSerializable("sort");
    }

    this.listFragment = (MovieListFragment) getSupportFragmentManager().findFragmentById(R.id.list_fragment);
    this.detailFragment = (InfoActivityFragment) getSupportFragmentManager()
            .findFragmentById(R.id.detail_fragment);

}

From source file:com.garrocho.MapActivity.java

@SuppressLint("NewApi")
@Override//from www  .  j  a  v a2 s.c o  m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_map);
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            musica = null;
        } else {
            musica = extras.getString("MUSICA");
        }
    } else {
        musica = (String) savedInstanceState.getSerializable("MUSICA");
    }

    mPrefs = new SimpleGeofenceStore(this);
    Intent intent = new Intent();
    intent.putStringArrayListExtra(String.valueOf(GeofenceUtils.LISTA_GEOFENCES_ADDED), null);

    mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    if (mMap != null) {

        mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);

        mMap.setOnMapLongClickListener(new OnMapLongClickListener() {

            @Override
            public void onMapLongClick(final LatLng point) {
                CameraPosition INIT = new CameraPosition.Builder()
                        .target(new LatLng(point.latitude, point.longitude)).zoom(17.5F).build();
                mMap.animateCamera(CameraUpdateFactory.newCameraPosition(INIT));

                // TODO Auto-generated method stub
                String names[] = { "25", "50", "100", "200", "400" };
                final AlertDialog alertDialog = new AlertDialog.Builder(MapActivity.this,
                        android.R.style.Theme_Translucent).create();
                LayoutInflater inflater = getLayoutInflater();
                View convertView = (View) inflater.inflate(R.layout.custom, null);
                alertDialog.setView(convertView);
                alertDialog.setTitle("Selecione um Radius");
                ListView lv = (ListView) convertView.findViewById(R.id.listView1);
                ArrayAdapter<String> adapter = new ArrayAdapter<String>(MapActivity.this,
                        android.R.layout.simple_list_item_1, names);
                lv.setAdapter(adapter);
                alertDialog.show();
                lv.setOnItemClickListener(new OnItemClickListener() {

                    @Override
                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
                        String item = ((TextView) arg1).getText().toString();

                        SimpleGeofence geofence = new SimpleGeofence(String.valueOf(mPrefs.getQtdeGeo() + 1),
                                point.latitude, point.longitude, Float.valueOf(item),
                                GEOFENCE_EXPIRATION_IN_MILLISECONDS, Geofence.GEOFENCE_TRANSITION_ENTER,
                                musica);

                        addMarkerForFence(geofence);
                        mPrefs.setGeofence(geofence.getId(), geofence);
                        lista.add(geofence.getId());
                        Intent intent = new Intent();
                        intent.putStringArrayListExtra(String.valueOf(GeofenceUtils.LISTA_GEOFENCES_ADDED),
                                lista);
                        MapActivity.this.setResult(Activity.RESULT_OK, intent);
                        alertDialog.dismiss();
                        Toast.makeText(MapActivity.this, "GeoFence Adicionada!", Toast.LENGTH_LONG).show();
                    }
                });
            }
        });

        desenharMakers();

        mMap.setMyLocationEnabled(true);

        Location location = mMap.getMyLocation();
        CameraPosition INIT = null;

        if (location == null) {
            locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
            location = getLastBestLocation();
        }

        INIT = new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude()))
                .zoom(17.5F).build();

        if (INIT != null)
            mMap.animateCamera(CameraUpdateFactory.newCameraPosition(INIT));
    }
}

From source file:com.s16.picker.colorpicker.ColorPickerDialog.java

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

    if (getArguments() != null) {
        mTitleResId = getArguments().getInt(KEY_TITLE_ID);
        mColumns = getArguments().getInt(KEY_COLUMNS);
        mSize = getArguments().getInt(KEY_SIZE);
    }/*from  www. ja  v  a2s.  c  o m*/

    if (savedInstanceState != null) {
        mColors = savedInstanceState.getIntArray(KEY_COLORS);
        mSelectedColor = (Integer) savedInstanceState.getSerializable(KEY_SELECTED_COLOR);
        mColorContentDescriptions = savedInstanceState.getStringArray(KEY_COLOR_CONTENT_DESCRIPTIONS);
    }
}

From source file:com.sanparks.sanscan.WizardEntryActivity.java

private boolean initialize(final Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        _imageUri = savedInstanceState.getParcelable(KEY_IMAGE_URI);
        _image = (Bitmap) getLastNonConfigurationInstance();
        _imageSource = (ImageSource) savedInstanceState.getSerializable(KEY_IMAGE_SOURCE);

        if (_image != null && _imageUri == null) {
            return false;
        }/* w  w  w .  j  av a2s . c  o m*/
    }
    return true;
}

From source file:com.example.android.foodrecipes.app.RecipeSearchFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_recipe_descriptions, container, false);

    Bundle args = getArguments();
    if (args != null) {
        mAutoLoadFirstRecipe = args.getBoolean(AUTO_LOAD_FIRST_RECIPE);
        lastRecipeIdKey = args.getString(LAST_SHOWN_RECIPE_ID_KEY_NAME);

        RecipesLoaderAdapterFactory factory = (RecipesLoaderAdapterFactory) args
                .getSerializable(LOADER_ADAPTER_FACTORY);
        if (factory != null)
            mLoaderAdapter = factory.newLoaderAdapter();

        mEnableLoadOnScroll = args.getBoolean(ENABLE_LOAD_ON_SCROLL);

        mProgressDialog = UIUtil.createAndShowDefaultProgressDialog(getActivity());

        if (mAutoLoadFirstRecipe) {
            mProgressDialog.dismiss();//  w w w.  ja v  a2 s . co m
            if (!mNoActiveLoading) //don't show the dialog if the data has already been loaded
                mProgressDialog.show();
        }

        mProgressDialog.setOnKeyListener(new Dialog.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    if (mLoaderAdapter != null)
                        mLoaderAdapter.cancelLoading();
                    mProgressDialog.dismiss();
                }
                return true;
            }
        });

        mRecipesAdapter = new RecipesAdapter(getActivity());
        mOfflineItems = (LinearLayout) rootView.findViewById(R.id.offline_items);
        mRecipesGridView = (GridView) rootView.findViewById(R.id.gridview_recipes);
        mRecipesGridView.setAdapter(mRecipesAdapter);

        mRecipesGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                Recipe recipe = (Recipe) adapterView.getItemAtPosition(position);
                if (recipe != null) {
                    String id = recipe.getExternalId();
                    PrefsUtil.updateLastShownRecipeId(getActivity(), id, lastRecipeIdKey);
                    ((Callback) getActivity()).onItemSelected(id);
                }
            }
        });

        if (mEnableLoadOnScroll)
            mRecipesGridView.setOnScrollListener(new RecipesGridScrollListener());

        mRecipeText = (EditText) rootView.findViewById(R.id.recipe_query_text);

        boolean showSearchQueryInput = args.getBoolean(SHOW_SEARCH_QUERY_INPUT);
        if (showSearchQueryInput) {
            mRecipeText.setVisibility(View.VISIBLE);
            mRecipeText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                @Override
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if (actionId == IME_ACTION_DONE || actionId == IME_ACTION_NEXT) {
                        mCurrentQuery = mRecipeText.getText().toString();
                        if (!mCurrentQuery.isEmpty()) {
                            resetSearchState();
                            mLoaderAdapter.startLoading();
                            mProgressDialog.show();
                            mNoActiveLoading = false;
                            mRecipeText.clearFocus();
                            UIUtil.hideSoftKeyboard(getActivity(), v);
                            //scroll to the top of grid, after the new search is initiated
                            mRecipesGridView.smoothScrollToPosition(0);
                            PrefsUtil.updateLastRecipe(getActivity(), mCurrentQuery);
                        }

                        return true;
                    }
                    return false;
                }
            });
        } else {
            mRecipeText.setVisibility(View.GONE);
        }
    }

    return rootView;
}

From source file:com.mario22gmail.license.nfc_project.FragmentSecureNotes.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_secure_notes, container, false);
    rootView.setTag(TAG);//from w w  w.j  av  a2 s . com
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_viewSecureNotes);

    mLayoutManager = new LinearLayoutManager(getActivity());
    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    secureNotesAdapter = new SecureNotesAdapter(secureNotesDataSet);
    mRecyclerView.setAdapter(secureNotesAdapter);

    Intent setTitleIntent = new Intent("fragment.setTitle");
    setTitleIntent.putExtra("Title", "Continut card");
    NavigationDrawerActivity.getAppContext().sendBroadcast(setTitleIntent);

    return rootView;
}

From source file:com.noah.lol.network.RequestNetwork.java

protected void asyncRequestGet(final String url, final NetworkListener<String> listener) {

    if (url == null) {
        return;/*from  w  w  w  . j a  va 2 s  .  co  m*/
    }

    try {
        environmentCheck();
    } catch (EnvironmentException e) {
        if (listener != null) {
            e.setStatus(BAD_REQUEST_ENVIRONMENT_CONFIG);
            listener.onNetworkFail(BAD_REQUEST_ENVIRONMENT_CONFIG, e);
        }
        return;
    }

    final Handler handler = new Handler() {

        @Override
        public void handleMessage(Message msg) {
            Bundle bundle = msg.getData();
            switch (msg.what) {
            case REQUEST_SUCCESS:
                String responseBody = bundle.getString(RESPONSE_KEY);

                if (listener != null && responseBody != null) {
                    listener.onSuccess(responseBody);
                }
                break;
            case REQUEST_FAIL:
                NetworkException e = (NetworkException) bundle.getSerializable(EXCEPTION_KEY);
                if (listener != null) {
                    listener.onNetworkFail(e.getStatus(), e);
                }
                break;
            }
        }
    };

    new Thread(new Runnable() {

        @Override
        public void run() {

            String responseBody = null;
            Message message = new Message();

            try {
                responseBody = syncRequestGet(url);
                Bundle bundle = new Bundle();
                bundle.putString(RESPONSE_KEY, responseBody);
                message = Message.obtain(handler, REQUEST_SUCCESS);
                message.setData(bundle);
                handler.sendMessage(message);
            } catch (NetworkException e) {
                Bundle bundle = new Bundle();
                bundle.putSerializable(EXCEPTION_KEY, e);
                message = Message.obtain(handler, REQUEST_FAIL);
                message.setData(bundle);
                handler.sendMessage(message);
                e.printStackTrace();
            }

        }
    }).start();

}

From source file:dev.dworks.widgets.adateslider.PickerDialogFragment.java

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

    Bundle args = getArguments();
    if (args != null && args.containsKey(REFERENCE_KEY)) {
        mLayoutID = args.getInt(REFERENCE_KEY);
    }/*from w  w  w  .  ja v  a  2 s.c o m*/
    if (args != null && args.containsKey(THEME_RES_ID_KEY)) {
        mTheme = args.getInt(THEME_RES_ID_KEY);
    }
    if (args != null && args.containsKey(INITIAL_TIME_KEY)) {
        mInitialTime = (Calendar) args.getSerializable(INITIAL_TIME_KEY);
    }
    if (args != null && args.containsKey(MIN_TIME_KEY)) {
        minTime = (Calendar) args.getSerializable(MIN_TIME_KEY);
    }
    if (args != null && args.containsKey(MAX_TIME_KEY)) {
        maxTime = (Calendar) args.getSerializable(MAX_TIME_KEY);
    }
    if (args != null && args.containsKey(MINUTE_INTERVAL_KEY)) {
        this.minuteInterval = args.getInt(MINUTE_INTERVAL_KEY);
    }

    mInitialTime = Calendar.getInstance(mInitialTime.getTimeZone());
    mInitialTime.setTimeInMillis(mInitialTime.getTimeInMillis());

    if (minuteInterval > 1) {
        int minutes = mInitialTime.get(Calendar.MINUTE);
        int diff = ((minutes + minuteInterval / 2) / minuteInterval) * minuteInterval - minutes;
        mInitialTime.add(Calendar.MINUTE, diff);
    }
    setStyle(DialogFragment.STYLE_NO_TITLE, 0);

    // Init defaults
    mTextColor = getResources().getColorStateList(R.color.dialog_text_color_holo_dark);
    mButtonBackgroundResId = R.drawable.button_background_dark;
    mDividerColor = getResources().getColor(R.color.default_divider_color_dark);
    mDialogBackgroundResId = R.drawable.dialog_full_holo_dark;

    if (savedInstanceState != null) {
        Calendar c = (Calendar) savedInstanceState.getSerializable("time");
        if (c != null) {
            mInitialTime = c;
        }
    }

    if (mTheme != -1) {

        TypedArray a = getActivity().getApplicationContext().obtainStyledAttributes(mTheme,
                R.styleable.PickersDialogFragment);

        mTextColor = a.getColorStateList(R.styleable.PickersDialogFragment_textColor);
        mButtonBackgroundResId = a.getResourceId(R.styleable.PickersDialogFragment_buttonBackground,
                mButtonBackgroundResId);
        mDividerColor = a.getColor(R.styleable.PickersDialogFragment_dividerColor, mDividerColor);
        mDialogBackgroundResId = a.getResourceId(R.styleable.PickersDialogFragment_dialogBackground,
                mDialogBackgroundResId);
        a.recycle();
    }
}