Example usage for android.content Intent getSerializableExtra

List of usage examples for android.content Intent getSerializableExtra

Introduction

In this page you can find the example usage for android.content Intent getSerializableExtra.

Prototype

public Serializable getSerializableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.androidpi.bricks.gallery.lru.ImageDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    final List<ImageFileEntry> entries = (ArrayList<ImageFileEntry>) intent
            .getSerializableExtra(EXTRA_IMAGE_ENTRIES);
    final int currentItem = intent.getIntExtra(EXTRA_CURRENT_ENTRY_POS, -1);
    // Set up ViewPager and backing adapter
    // mAdapter = new ImagePagerAdapter(getSupportFragmentManager(),
    // Images.imageUrls.length);
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), entries);
    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(mAdapter);/*from  ww  w  . j  a v a 2  s  .co m*/
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.horizontal_page_margin));
    mPager.setOffscreenPageLimit(2);

    mTvEdit = (TextView) findViewById(R.id.tv_edit);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to
    // create a more
    // immersive photo viewing experience
    if (AppUtil.hasHoneycomb()) {
        final ActionBar actionBar = getSupportActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                } else {
                    actionBar.show();
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity

    if (currentItem != -1) {
        mPager.setCurrentItem(currentItem);
    }

    // Fetch screen height and width, to use as our max size when loading
    // images as this
    // activity runs full screen
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    // For this sample we'll use half of the longest width to resize our
    // images. As the
    // image scaling ensures the image is larger than this, we should be
    // left with a
    // resolution that is appropriate for both portrait and landscape. For
    // best image quality
    // we shouldn't divide by 2, but this will use more memory and require a
    // larger memory
    // cache.
    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of
    // app memory

    // The ImageFetcher takes care of loading images into our ImageView
    // children asynchronously
    mImageResizer = new ImageResizer(this, longest);
    mImageResizer.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageResizer.setImageFadeIn(false);

    mTvEdit.setOnClickListener(this);
}

From source file:com.indragie.cmput301as1.ExpenseClaimListFragment.java

/**
 * Mutates expense claims by removing or editing tags based on the mutations
 * contained within the intent./*from w w  w .j  a v a2 s .  c  om*/
 * @param data The intent to get the list of mutations fron.
 */
@SuppressWarnings("unchecked")
private void onManageTagsResult(Intent data) {
    ArrayList<ManageTagsActivity.TagMutation> mutations = (ArrayList<ManageTagsActivity.TagMutation>) data
            .getSerializableExtra(ManageTagsActivity.EXTRA_TAG_MUTATIONS);
    controller.processTagMutations(mutations);
}

From source file:com.example.ali.topcoderandroid.Activities.ChallengeDetailActivity.java

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

    Intent i = getIntent();
    //challengeId =  i.getStringExtra(CHALLENGE_ID_TAG);
    challenge = (ChallengeModel) i.getSerializableExtra(CHALLENGE_ID_TAG);

    if (challenge != null) {

        Toolbar detail_toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
        if (detail_toolbar != null) {
            setSupportActionBar(detail_toolbar);
            getSupportActionBar().setTitle(challenge.getChallengeName());
        }/*from  w w w . j av  a 2 s  . co m*/

        fetchChallengeDetail(challenge);

    }

    //init for snackbar
    detail_content_container = (CoordinatorLayout) findViewById(R.id.detail_content_container);

}

From source file:io.github.runassudo.ptoffline.activities.TripsActivity.java

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

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

    TransportNetwork network = Preferences.getTransportNetwork(this);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        if (network != null)
            toolbar.setSubtitle(network.getName());
        setSupportActionBar(toolbar);//  ww w  .j ava  2 s . c  o m

        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null)
            actionBar.setDisplayHomeAsUpEnabled(true);
    }

    final Intent intent = getIntent();
    start_context = (QueryTripsResult) intent
            .getSerializableExtra("io.github.runassudo.ptoffline.pte.dto.QueryTripsResult");
    end_context = start_context;

    // retrieve trip data from intent that is not stored properly in trip object
    from = (Location) intent.getSerializableExtra("io.github.runassudo.ptoffline.pte.dto.Trip.from");
    via = (Location) intent.getSerializableExtra("io.github.runassudo.ptoffline.pte.dto.Trip.via");
    to = (Location) intent.getSerializableExtra("io.github.runassudo.ptoffline.pte.dto.Trip.to");
    products = (ArrayList<Product>) intent
            .getSerializableExtra("io.github.runassudo.ptoffline.pte.dto.Trip.products");

    swipeRefresh = (SwipyRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    swipeRefresh.setColorSchemeResources(R.color.accent);
    swipeRefresh.setDistanceToTriggerSync(getDragDistance(this));

    mRecyclerView = (RecyclerView) findViewById(R.id.trips_recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setHasFixedSize(true);

    final SwipeDismissRecyclerViewTouchListener touchListener = new SwipeDismissRecyclerViewTouchListener(
            mRecyclerView, new SwipeDismissRecyclerViewTouchListener.DismissCallbacks() {
                @Override
                public boolean canDismiss(int position) {
                    return true;
                }

                @Override
                public void onDismiss(RecyclerView recyclerView, int[] reverseSortedPositions) {
                    for (int position : reverseSortedPositions) {
                        mAdapter.removeItemAt(position);
                        Snackbar snackbar = Snackbar.make(recyclerView, R.string.trip_removed,
                                Snackbar.LENGTH_LONG);
                        snackbar.setAction(R.string.undo, new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                mAdapter.undo();
                            }
                        });
                        snackbar.show();
                    }
                }

                @Override
                public void onItemClick(int position) {
                    Trip trip = mAdapter.getItem(position).trip;

                    Intent intent = new Intent(TripsActivity.this, TripDetailActivity.class);
                    intent.putExtra("io.github.runassudo.ptoffline.pte.dto.Trip", trip);
                    intent.putExtra("io.github.runassudo.ptoffline.pte.dto.Trip.from", from);
                    intent.putExtra("io.github.runassudo.ptoffline.pte.dto.Trip.via", via);
                    intent.putExtra("io.github.runassudo.ptoffline.pte.dto.Trip.to", to);
                    intent.putExtra("io.github.runassudo.ptoffline.pte.dto.Trip.products", products);

                    int pos = mAdapter.getPosition(trip);
                    ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                            TripsActivity.this, mRecyclerView.findViewHolderForAdapterPosition(pos).itemView,
                            trip.getId());
                    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N_MR1) {
                        // work around #285
                        startActivity(intent);
                    } else {
                        ActivityCompat.startActivity(TripsActivity.this, intent, options.toBundle());
                    }
                }
            });

    // Setting this scroll listener is required to ensure that during ListView scrolling, we don't look for swipes.
    mRecyclerView.setOnScrollListener(touchListener.makeScrollListener());
    // TODO also make sure a swipe prevents scrolling

    final boolean showLineName = network != null && network.hasGoodLineNames();
    ;

    mAdapter = new TripAdapter(ListTrip.getList(start_context.trips), touchListener, this, showLineName);
    mAdapter.setHasStableIds(false);
    mRecyclerView.setAdapter(mAdapter);

    if (to.type != LocationType.COORD && from.type != LocationType.COORD) {
        isFav = RecentsDB.isFavedRecentTrip(this, new RecentTrip(from, via, to));
        isFavable = true;
    } else {
        isFav = false;
        isFavable = false;
    }
}

From source file:com.nadmm.airports.wx.PirepFragment.java

protected void showPirep(Intent intent) {
    Pirep pirep = (Pirep) intent.getSerializableExtra(NoaaService.RESULT);

    LinearLayout layout = (LinearLayout) findViewById(R.id.pirep_entries_layout);
    layout.removeAllViews();//ww  w  .  j av  a 2 s.  c o m

    if (!pirep.entries.isEmpty()) {
        TextView tv = (TextView) findViewById(R.id.pirep_title_msg);
        tv.setText(String.format("%d PIREPs reported within %d NM of %s during last %d hours",
                pirep.entries.size(), PIREP_RADIUS_NM, mStationId, PIREP_HOURS_BEFORE));
        for (PirepEntry entry : pirep.entries) {
            showPirepEntry(layout, entry);
        }
    } else {
        TextView tv = (TextView) findViewById(R.id.pirep_title_msg);
        tv.setText(String.format("No PIREPs reported within %d NM of %s in last %d hours", PIREP_RADIUS_NM,
                mStationId, PIREP_HOURS_BEFORE));
    }

    TextView tv = (TextView) findViewById(R.id.wx_fetch_time);
    tv.setText("Fetched on " + TimeUtils.formatDateTime(getActivity(), pirep.fetchTime));
    tv.setVisibility(View.VISIBLE);

    stopRefreshAnimation();
    setFragmentContentShown(true);
}

From source file:org.lytsing.android.weibo.ui.StatusDetailActivity.java

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

    setContentView(R.layout.detail);/*  w w w .  j a  va 2  s  .com*/
    api = new CommentsAPI(mAccessToken);
    Intent i = this.getIntent();
    mStatus = (Statuses) i.getSerializableExtra(Consts.STATUSES_KEY);
    initView();
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Fragments.NodeListFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Edit edit;/*from  ww  w . j  a  v a 2  s . com*/
    switch (resultCode) {
    case FragmentActivity.RESULT_OK:
        edit = new UpdateNodeEdit(session, data.getExtras().getInt("index"),
                (Node) data.getSerializableExtra("node"));
        edit.perform();
        break;
    case EditNodeScreen.RESULT_DELETE:
        edit = new RemoveNodeEdit(session, data.getExtras().getInt("index"));
        edit.perform();
        break;
    }
}

From source file:edu.ucsb.cs.cs185.inspirante.editentry.SelectCoverFragment.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
        if (data != null && requestCode == FRAGMENT_PICK_IMAGE) {
            ArrayList<ImageItem> images = (ArrayList<ImageItem>) data
                    .getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
            mItemCard.addImages(images);
            mAdapter.notifyDataSetChanged();

            setAddImageButton();/*  www.  j  a  v  a  2s.c  om*/

        } else {
            Toast.makeText(getContext(), "No data", Toast.LENGTH_SHORT).show();
        }
    }

}

From source file:eisene.riskspeedtools.TimerSetupFrag.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == COLOR_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            Color newColor = (Color) data.getSerializableExtra(ColorSelectorActivity.RESULT_ID_KEY);
            int player = Converters.buttonIdToPlayer(data.getIntExtra(BUTTON_ID_KEY, 1));
            mPresenter.updatePlayerColor(player, newColor);
        }//from   w ww.j a  va2  s. c om
    } else if (requestCode == NUM_PLAYERS_REQUEST_CODE) {
        if (resultCode == Activity.RESULT_OK) {
            int numPlayers = data.getIntExtra(NumPlayerSelectorActivity.RESULT_ID_KEY, 1);
            mPresenter.setNumberOfPlayers(numPlayers);
        }
    }
}

From source file:com.example.cuisoap.agrimac.homePage.machineDetail.machineDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_machine_detail);
    InitViewPager();/*from  ww w  .j a v a 2  s .c  om*/
    Intent i = getIntent();
    data = (HashMap<String, String>) i.getSerializableExtra("data");
    machineDetailData.putData(data);
    delete = (LinearLayout) findViewById(R.id.machine_delete_layout);
    edit = (LinearLayout) findViewById(R.id.machine_edit_layout);
    comment = (LinearLayout) findViewById(R.id.machine_comment_layout);
    edit_image = (ImageView) findViewById(R.id.machine_edit_pic);
    edit_text = (TextView) findViewById(R.id.machine_edit_text);
    delete.setOnClickListener(l);
    edit.setOnClickListener(l);
    comment.setOnClickListener(l);
    filelist = new HashMap<>();
    machineDetailData.context = getApplicationContext();
}