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:pl.bcichecki.rms.client.android.activities.NewMessageActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_message);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    context = this;

    messagesRestClient = new MessagesRestClient(this, UserProfileHolder.getUsername(),
            UserProfileHolder.getPassword(), SharedPreferencesWrapper.getServerRealm(),
            SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(),
            SharedPreferencesWrapper.getWebserviceContextPath());
    usersRestClient = new UsersRestClient(this, UserProfileHolder.getUsername(),
            UserProfileHolder.getPassword(), SharedPreferencesWrapper.getServerRealm(),
            SharedPreferencesWrapper.getServerAddress(), SharedPreferencesWrapper.getServerPort(),
            SharedPreferencesWrapper.getWebserviceContextPath());

    subjectEditText = (EditText) findViewById(R.id.activity_new_message_subject_text);
    recipentsEditText = (EditText) findViewById(R.id.activity_new_message_recipents_text);
    recipentsAddButton = (Button) findViewById(R.id.activity_new_message_recipents_add);
    contentEditText = (EditText) findViewById(R.id.activity_new_message_content_text);

    subjectEditText.setOnClickListener(new View.OnClickListener() {

        @Override//w  w w.  j a v a 2 s. co  m
        public void onClick(View v) {
            ((EditText) v).setError(null);
        }
    });
    contentEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ((EditText) v).setError(null);
        }
    });

    recipentsAddButton.setEnabled(false);
    recipentsAddButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (recipentsListDialog != null) {
                recipentsListDialog.show();
            }
        }
    });

    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras != null) {
            replyMessage = (Message) extras.getSerializable(MESSAGE_EXTRA);
        }
    } else {
        replyMessage = (Message) savedInstanceState.getSerializable(MESSAGE_EXTRA);
    }

    if (replyMessage == null) {
        Log.d(TAG, "External recipent not received! Users will be loaded...");
        loadUsers();
    } else {
        Log.d(TAG, "External recipent received! Adding users is not possible.");
        setUpForm();
        updateRecipentsEditText();
    }
}

From source file:com.example.mapdemo.LiteListDemoActivity.java

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

    // creating GPS Class object
    // User location
    gps = new GPSTracker(this);
    Bundle b = getIntent().getExtras();

    nearPlaces = (PlacesList) b.getSerializable("near_places");
    places = nearPlaces.results;/*from   www .  j a  v  a2s .  c  o m*/

    LIST_LOCATIONS = new NamedLocation[nearPlaces.results.size()];
    imageUrls = new String[nearPlaces.results.size()];

    // TODO This i++ resembles C. Can be buggy memory leaks
    int i = 0;
    for (Place place : places) {
        // creating new HashMap
        HashMap<String, String> placesmap = new HashMap<String, String>();
        HashMap<String, NamedLocation> locationsmap = new HashMap<String, NamedLocation>();
        placesmap.put(KEY_ID, place.id);
        placesmap.put(KEY_ID, place.name);
        placesmap.put(KEY_ADDRESS, place.address);
        placesmap.put(KEY_THUMB_URL, place.office_image_url);
        placesList.add(placesmap);
        // Array to sort locations
        LIST_LOCATIONS[i] = new NamedLocation(place.name, new LatLng(place.location.lat, place.location.lng),
                place.formatted_phone_number, place.address, place.office_image_url, place.vicinity);

        locationmapList.add(locationsmap);
        locations.add(new NamedLocation(place.name, new LatLng(place.location.lat, place.location.lng),
                place.formatted_phone_number, place.address, place.office_image_url, place.vicinity));

        // Get image URL's
        imageUrls[i] = place.office_image_url;
        i++;
    }

    Collections.sort(locations);

    //  list=(ListView)findViewById(R.id.listview);
    // Getting adapter by passing xml data ArrayList
    //    lAdapter=new LazyAdapter(this.getApplicationContext(), places);
    //   list.setAdapter(lAdapter);
    GoogleType obj = b.getParcelable("GoogleType");

    // Set a custom list adapter for a list of locations
    mAdapter = new MapAdapter(this, R.layout.lite_list_demo_row, locations);

    // Set a custom list adapter for a list of locations
    //     mAdapter = new MapAdapter(this, locations_list);
    mList = (ListFragment) getSupportFragmentManager().findFragmentById(R.id.list);
    mList.setListAdapter(mAdapter);

    mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    // Set a RecyclerListener to clean up MapView from ListView
    AbsListView lv = mList.getListView();
    lv.setRecyclerListener(mRecycleListener);
}

From source file:com.miqtech.master.client.ui.PersonalHomePhotoActivity.java

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

    initImageLoader(this);
    context = this;

    Bundle bundle = getIntent().getExtras();
    images = (List<UserImage>) bundle.getSerializable(IMAGES);
    isMyShelf = bundle.getBoolean("isMyShelf", false);
    int pagerPosition = bundle.getInt(IMAGE_POSITION, 0);
    isFromComment = bundle.getBoolean("isFromComment", false);

    if (savedInstanceState != null) {
        pagerPosition = savedInstanceState.getInt(STATE_POSITION);
    }//  w  w w.  j a va 2s.c  o  m

    options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.default_img)
            .showImageOnFail(R.drawable.default_img).resetViewBeforeLoading(true).cacheOnDisc(true)
            .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.ARGB_8888)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    pager = (HackyViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter(images, this));
    pager.setCurrentItem(pagerPosition);
    pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {
            photo_number.setText((position + 1) + "/" + images.size());
        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });
    mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);
    photo_number = (TextView) findViewById(R.id.photo_number);
    if (isFromComment) {
        photo_number.setVisibility(View.GONE);
    } else {
        photo_number.setText((pagerPosition + 1) + "/" + images.size());
    }
    mIndicator.setViewPager(pager);
}

From source file:fi.mikuz.boarder.gui.internet.DownloadBoardList.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.internet_download);
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    mViewPager = (ViewPager) findViewById(R.id.viewPager);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override// w  ww .jav a2 s .  co  m
        public void onPageSelected(int position) {
            setPageTitle(position + 1);
        }
    });

    setNewViewPager();
    mSearch = (EditText) findViewById(R.id.searchInput);
    mCurrentSearch = "";
    ImageView refresh = (ImageView) findViewById(R.id.refresh);

    Button orderByDate = (Button) findViewById(R.id.orderByDate);
    Button orderByRate = (Button) findViewById(R.id.orderByRate);
    mOrderRule = ORDER_RULE_CHANGE_TIME;
    mOrderDirection = ORDER_DIRECTION_DESCENDING;
    mMaxResults = 40;

    Bundle extras = getIntent().getExtras();
    if (extras.getSerializable(InternetMenu.LOGIN_KEY) != null) {
        @SuppressWarnings("unchecked")
        HashMap<String, String> lastSession = (HashMap<String, String>) extras
                .getSerializable(InternetMenu.LOGIN_KEY);

        mLoggedIn = true;
        mUserId = lastSession.get(InternetMenu.USER_ID_KEY);
        mSessionToken = lastSession.get(InternetMenu.SESSION_TOKEN_KEY);
    }

    mSearch.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent event) {
            String search = mSearch.getText().toString();
            if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_DOWN
                    && !search.equals(mCurrentSearch)) {
                mCurrentSearch = search;
                setNewViewPager();
            }
            return true;
        }
    });

    refresh.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            refreshViewPager();
        }
    });

    orderByDate.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mOrderRule.equals(ORDER_RULE_CHANGE_TIME)
                    && mOrderDirection.equals(ORDER_DIRECTION_DESCENDING)) {
                mOrderDirection = ORDER_DIRECTION_ASCENDING;
            } else {
                mOrderRule = ORDER_RULE_CHANGE_TIME;
                mOrderDirection = ORDER_DIRECTION_DESCENDING;
            }
            setNewViewPager();
        }
    });

    orderByRate.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mOrderRule.equals(ORDER_RULE_BOARD_RATING)
                    && mOrderDirection.equals(ORDER_DIRECTION_DESCENDING)) {
                mOrderDirection = ORDER_DIRECTION_ASCENDING;
            } else {
                mOrderRule = ORDER_RULE_BOARD_RATING;
                mOrderDirection = ORDER_DIRECTION_DESCENDING;
            }
            setNewViewPager();
        }
    });

}

From source file:com.janela.mobile.ui.repo.RepositoryListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Activity activity = getActivity();// w w  w  .  j a  v a2s  .  c o  m
    User currentOrg = ((OrganizationSelectionProvider) activity).addListener(this);
    if (currentOrg == null && savedInstanceState != null)
        currentOrg = (User) savedInstanceState.getSerializable(EXTRA_USER);
    org.set(currentOrg);
    if (currentOrg != null)
        recentRepos = new RecentRepositories(activity, currentOrg);

    setEmptyText(R.string.no_repositories);

    super.onActivityCreated(savedInstanceState);
}

From source file:com.github.mobile.ui.repo.RepositoryListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Activity activity = getActivity();/*from  w  ww .  j  a v  a 2 s  .  c  o  m*/
    User currentOrg = ((OrganizationSelectionProvider) activity).addListener(this);
    if (currentOrg == null && savedInstanceState != null)
        currentOrg = (User) savedInstanceState.getSerializable(EXTRA_USER);
    org.set(currentOrg);
    if (currentOrg != null)
        recentRepos = new RecentRepositories(activity, currentOrg);

    setEmptyText(string.no_repositories);

    super.onActivityCreated(savedInstanceState);
}

From source file:com.github.chenxiaolong.dualbootpatcher.pathchooser.PathChooserDialog.java

@SuppressWarnings("ConstantConditions")
@NonNull/*from  w w w .j a v  a2  s.  c o  m*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();
    mBuilder = (Builder) args.getSerializable(ARG_BUILDER);
    mTarget = (DialogListenerTarget) args.getSerializable(ARG_TARGET);
    mTag = args.getString(ARG_TAG);

    switch (mBuilder.mType) {
    case OPEN_DIRECTORY:
        mComparator = DIRECTORY_COMPARATOR;
        break;
    case OPEN_FILE:
    case SAVE_FILE:
        mComparator = PATH_COMPARATOR;
        break;
    }

    if (savedInstanceState != null) {
        mCwd = new File(savedInstanceState.getString(EXTRA_CWD));
    } else {
        mCwd = new File(mBuilder.mInitialPath);
    }

    mAdapter = new PathChooserItemAdapter(mNames, this);
    refreshContents();

    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity());
    builder.title(mCwd.getAbsolutePath());
    builder.customView(R.layout.dialog_path_chooser, false);
    builder.onNegative(this);
    builder.autoDismiss(false);
    builder.negativeText(R.string.cancel);

    if (mBuilder.mType == Type.OPEN_DIRECTORY) {
        builder.onPositive(this);
        builder.positiveText(R.string.path_chooser_choose_label);
    } else if (mBuilder.mType == Type.SAVE_FILE) {
        builder.onPositive(this);
        builder.positiveText(R.string.path_chooser_save_label);
        builder.onNeutral(this);
        builder.neutralText(R.string.path_chooser_new_folder_label);
    }

    MaterialDialog dialog = builder.build();
    View view = dialog.getView();

    RecyclerView rv = (RecyclerView) view.findViewById(R.id.files);
    mEditText = (EditText) view.findViewById(R.id.filename);

    if (mBuilder.mType == Type.SAVE_FILE) {
        mEditText.addTextChangedListener(new NameValidationTextWatcher(dialog));
        mEditText.setText(mBuilder.mDefaultName);
    } else {
        mEditText.setVisibility(View.GONE);
    }

    rv.setHasFixedSize(true);
    rv.setAdapter(mAdapter);

    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    rv.setLayoutManager(llm);

    return dialog;
}

From source file:com.weebly.opus1269.copyeverywhere.ui.clipviewer.ClipViewerFragment.java

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

    // Check whether we're recreating a previously destroyed instance
    if (savedInstanceState != null) {
        // Restore value of members from saved state
        mClipItem = (ClipItem) savedInstanceState.getSerializable(STATE_CLIP_ITEM);
        mIsViewable = savedInstanceState.getBoolean(STATE_CLIP_VIEWABLE);
        mHighlightText = savedInstanceState.getString(STATE_CLIP_HIGHLIGHT);
    } else {//www  . j av  a2 s  .  c  o m
        mClipItem = new ClipItem();
        mHighlightText = "";
        mIsViewable = true;
    }
    mOnClipChanged.onClipChanged(mClipItem);
}

From source file:com.gh4a.activities.IssueMilestoneEditActivity.java

@Override
protected void onInitExtras(Bundle extras) {
    super.onInitExtras(extras);
    mRepoOwner = extras.getString(Constants.Repository.OWNER);
    mRepoName = extras.getString(Constants.Repository.NAME);
    mMilestone = (Milestone) extras.getSerializable(EXTRA_MILESTONE);
}

From source file:com.cloudkick.NodeViewActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    NodeViewState previousState = (NodeViewState) getLastNonConfigurationInstance();
    if (previousState != null) {
        node = previousState.node;/*from   ww w  . ja  v a2 s .  co  m*/
        checks = previousState.checks;
    } else {
        Bundle data = this.getIntent().getExtras();
        checks = new ArrayList<CKListItem>();
        checks.add(new CKListLoadingSpinner());
        node = (Node) data.getSerializable("node");
    }

    String inflater = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater li = (LayoutInflater) getSystemService(inflater);

    nodeView = new RelativeLayout(this);
    li.inflate(R.layout.node_view, nodeView, true);
    setContentView(nodeView);
    adapter = new CheckAdapter(this, checks);
    ((ListView) findViewById(R.id.node_detail_list)).setAdapter(adapter);
    ((ListView) findViewById(R.id.node_detail_list)).setOnItemClickListener(checkClickListener);
    redrawHeader();

    // If the name of the node changes we can't exactly refresh it anyway
    setTitle("Node: " + node.name);
    ((ImageView) findViewById(R.id.node_detail_separator)).bringToFront();
    reloadAPI();
}