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:name.gumartinm.weather.information.fragment.overview.OverviewFragment.java

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

    final ListView listWeatherView = this.getListView();
    listWeatherView.setChoiceMode(ListView.CHOICE_MODE_NONE);

    if (savedInstanceState != null) {
        // Restore UI state
        final Forecast forecast = (Forecast) savedInstanceState.getSerializable("Forecast");

        if (forecast != null) {
            final PermanentStorage store = new PermanentStorage(this.getActivity().getApplicationContext());
            store.saveForecast(forecast);
        }// ww  w.j av  a 2 s .  c o  m
    }

    this.setHasOptionsMenu(false);

    this.setEmptyText(this.getString(R.string.text_field_remote_error));
    this.setListShownNoAnimation(false);
}

From source file:org.ambientdynamix.core.HomeActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode == Activity.RESULT_OK) {
        final Bundle extras = intent.getExtras();
        switch (requestCode) {
        case ACTIVITY_EDIT:
            // Access the serialized app coming in from the Intent's Bundle
            // extra
            final DynamixApplication app = (DynamixApplication) extras.getSerializable("app");
            // Update the DynamixService with the updated application
            DynamixService.updateApplication(app);
            refresh();//from  w  w w  .j a  v  a  2s  .  co m
            break;
        }
    }
}

From source file:com.pindroid.activity.BrowseBookmarks.java

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

    if (isTwoPane()) {
        lastSelected = savedInstanceState.getParcelable(STATE_LASTBOOKMARK);
        lastViewType = (BookmarkViewType) savedInstanceState.getSerializable(STATE_LASTVIEWTYPE);
        if (lastSelected != null) {
            if (!lastViewType.equals(BookmarkViewType.EDIT)) {
                setBookmarkView(lastSelected, lastViewType);
            } else {
                onBookmarkEdit(lastSelected);
            }/*ww w  . j  av a  2s .  c o m*/
        }
    }
}

From source file:com.loadsensing.app.SensorsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sensor_list_view);

    // Get Intent parameters
    String XarxaSelected = "";
    Bundle extras = null;//from  w ww. j a  va2 s . c  o m
    if (savedInstanceState == null) {
        extras = getIntent().getExtras();
        if (extras == null) {
            XarxaSelected = null;
        } else {
            XarxaSelected = extras.getString("idxarxaselected");
        }
    } else {
        XarxaSelected = (String) savedInstanceState.getSerializable("XarxaSelected");
    }
    // adapter que mapeja la informaci del sensor amb els camps del layout
    SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.sensor_row_list_view,
            new String[] { "id", "sensor", "tipus", "descripcio", "poblacio", "canal" },
            new int[] { R.id.text1, R.id.text2, R.id.text3, R.id.text4, R.id.text5, R.id.text6 });

    SharedPreferences settings = getSharedPreferences("LoadSensingApp", Context.MODE_PRIVATE);
    String address = SERVER_HOST + "?IdXarxa=" + XarxaSelected + "&session="
            + settings.getString("session", "");
    Log.d(DEB_TAG, "Requesting to " + address);

    try {
        String jsonString = JsonClient.connectString(address);

        // Convertim la resposta string a un JSONArray
        JSONArray llistaSensorsArray = new JSONArray(jsonString);

        for (int i = 0; i < llistaSensorsArray.length(); i++) {
            JSONObject xarxaJSON = llistaSensorsArray.getJSONObject(i);
            sensors = new HashMap<String, String>();
            sensors.put("id", xarxaJSON.getString("id"));
            sensors.put("sensor", xarxaJSON.getString("sensor"));
            sensors.put("canal", xarxaJSON.getString("canal"));
            sensors.put("tipus", xarxaJSON.getString("tipus"));
            sensors.put("descripcio", xarxaJSON.getString("Descripcio"));
            sensors.put("poblacio", xarxaJSON.getString("Poblacio"));

            list.add(sensors);
        }

        setListAdapter(adapter);

    } catch (Exception ex) {
    }
}

From source file:com.hackaton.PostsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setReverseLayout(true);
    linearLayoutManager.setStackFromEnd(true);
    mRecyclerView.setLayoutManager(linearLayoutManager);

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mRecyclerViewPosition = (int) savedInstanceState.getSerializable(KEY_LAYOUT_POSITION);
        mRecyclerView.scrollToPosition(mRecyclerViewPosition);
        // TODO: RecyclerView only restores position properly for some tabs.
    }/*from  www. j  a  va  2 s  . co m*/

    switch (getArguments().getInt(KEY_TYPE)) {
    case TYPE_FEED:
        Log.d(TAG, "Restoring recycler view position (all): " + mRecyclerViewPosition);
        Query allPostsQuery = FirebaseUtil.getPostsRef();
        mAdapter = getFirebaseRecyclerAdapter(allPostsQuery);
        mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
            @Override
            public void onItemRangeInserted(int positionStart, int itemCount) {
                super.onItemRangeInserted(positionStart, itemCount);
                // TODO: Refresh feed view.
            }
        });
        break;
    case TYPE_HOME:

        break;
    default:
        throw new RuntimeException("Illegal post fragment type specified.");
    }
    mRecyclerView.setAdapter(mAdapter);
}

From source file:com.homerunsb.navigationdrawertest.CompanyListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.i(TAG, "onCreateView()");

    View rootView = inflater.inflate(R.layout.fragment_item_layout, container, false);
    rootView.setTag(TAG);/*from w  ww. j a  va  2s. c  o  m*/

    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.rv_itemList);
    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);

    Log.i(TAG, "mCompanyDataItems size () " + mCompanyDataItems.size());
    mCompanyAdapter = new CompanyListAdapter(mCompanyDataItems);
    // Set CustomAdapter as the adapter for RecyclerView.
    mRecyclerView.setAdapter(mCompanyAdapter);
    mRecyclerView.setNestedScrollingEnabled(false);

    setRecyclerViewLayoutManager(LayoutManagerType.GRID_LAYOUT_MANAGER);

    return rootView;
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Activities.MapScreen.MapScreen.java

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

    boolean isFirstStart = savedInstanceState == null;
    // If we get created for the first time we get our data from the intent
    Bundle data = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
    session = (Session) data.getSerializable(Session.IDENTIFIER);

    locManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    mapView = (MapView) findViewById(R.id.mapView);
    mapView.setClickable(true);/*from  w  w  w.j a v a2 s.co  m*/
    mapView.setLongClickable(true);
    mapView.setBuiltInZoomControls(true);
    mapView.getFileSystemTileCache().setPersistent(false);

    getSupportActionBar().setSubtitle(session.getSelectedAlgorithm().toString());
    initializeHandler();

    setupWayOverlay();

    setupGPS(savedInstanceState, isFirstStart);

    if (session.getResult() != null) {
        updateDistancePopup();
        if (session.getResult().getPoints() != null) {
            mapView.setCenter(session.getResult().getPoints().get(0).getGeoPoint());
        }
    }
    if (!mapView.getMapPosition().isValid()) {
        mapView.setCenter(new GeoPoint(51.33, 10.45));
    }

    mapView.getOverlays().add(nodeOverlay);

    session.registerListener(NodeOverlay.class, nodeOverlay);
    session.registerListener(MapScreen.class, this);
}

From source file:com.barak.pix.PostsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setReverseLayout(true);
    linearLayoutManager.setStackFromEnd(true);
    mRecyclerView.setLayoutManager(linearLayoutManager);

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mRecyclerViewPosition = (int) savedInstanceState.getSerializable(KEY_LAYOUT_POSITION);
        mRecyclerView.scrollToPosition(mRecyclerViewPosition);
        // TODO: RecyclerView only restores position properly for some tabs.
    }//from  www. j ava 2 s .c o m

    switch (getArguments().getInt(KEY_TYPE)) {
    case TYPE_FEED:
        Query allPostsQuery = FirebaseUtil.getPostsRef();
        mAdapter = getFirebaseRecyclerAdapter(allPostsQuery);
        mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
            @Override
            public void onItemRangeInserted(int positionStart, int itemCount) {
                super.onItemRangeInserted(positionStart, itemCount);
                // TODO: Refresh feed view.
            }
        });
        break;
    case TYPE_HOME:
        mDetailView.setVisibility(View.VISIBLE);

        break;
    default:
        throw new RuntimeException("Illegal post fragment type specified.");
    }
    mRecyclerView.setAdapter(mAdapter);
}

From source file:com.irccloud.android.fragment.SpamFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context ctx = getActivity();
    if (ctx == null)
        return null;

    if (server == null && savedInstanceState != null && savedInstanceState.containsKey("cid"))
        server = ServersList.getInstance().getServer(savedInstanceState.getInt("cid"));

    if (server == null)
        throw new IllegalArgumentException("invalid CID");

    if (buffers == null && savedInstanceState != null && savedInstanceState.containsKey("buffers")) {
        buffers = (ArrayList<Buffer>) savedInstanceState.getSerializable("buffers");
    } else {/*from  www . jav a2s.  co m*/
        buffers = new ArrayList<>();
        for (Buffer b : BuffersList.getInstance().getBuffersForServer(server.getCid())) {
            if (b.getArchived() == 0 && b.getType().equals("conversation"))
                buffers.add(b);
        }
    }

    ArrayList<String> itemsList = new ArrayList<>();
    for (Buffer b : buffers) {
        itemsList.add(b.getName());
    }

    if (buffersToRemove == null && savedInstanceState != null
            && savedInstanceState.containsKey("buffersToRemove")) {
        buffersToRemove = (ArrayList<Buffer>) savedInstanceState.getSerializable("buffersToRemove");
    } else {
        buffersToRemove = new ArrayList<>(buffers);
    }

    CharSequence[] items = itemsList.toArray(new CharSequence[itemsList.size()]);
    LayoutInflater inflater = LayoutInflater.from(ctx);
    View v = inflater.inflate(R.layout.dialog_spam, null);
    listView = v.findViewById(android.R.id.list);
    listView.setAdapter(new ArrayAdapter<>(ctx, R.layout.row_spam, items));

    for (int i = 0; i < buffers.size(); i++) {
        listView.setItemChecked(i, buffersToRemove.contains(buffers.get(i)));
    }

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
            SparseBooleanArray checked = listView.getCheckedItemPositions();
            buffersToRemove.clear();
            for (int i = 0; i < buffers.size(); i++) {
                if (checked.get(i, false))
                    buffersToRemove.add(buffers.get(i));
            }
        }
    });

    return new AlertDialog.Builder(ctx).setView(v)
            .setPositiveButton("Delete", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    for (Buffer b : buffersToRemove) {
                        NetworkConnection.getInstance().deleteBuffer(b.getCid(), b.getBid());
                    }

                    new AlertDialog.Builder(ctx)
                            .setTitle(server.getName() + " (" + server.getHostname() + ":" + (server.getPort())
                                    + ")")
                            .setMessage(buffersToRemove.size() + " conversations were deleted")
                            .setNegativeButton("Close", null).show();
                }
            }).setNegativeButton("Cancel", null).create();
}

From source file:com.mycelium.wallet.lt.activity.buy.AdSearchFragment.java

@SuppressWarnings("unchecked")
@Override/*from   ww w .  j a va2s.c  o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = checkNotNull(inflater.inflate(R.layout.lt_ad_search_fragment, container, false));
    setHasOptionsMenu(true);
    if (savedInstanceState != null) {
        // May be null
        _ads = (List<AdSearchItem>) savedInstanceState.getSerializable(ADS);
    }
    view.findViewById(R.id.btChange).setOnClickListener(changeLocationClickListener);
    return view;
}