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.example.android.mediarouter.player.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Be sure to call the super class.
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mPlayer = (Player) savedInstanceState.getSerializable("mPlayer");
    }//from   ww  w .j  a v a2  s.  c  o m

    // Get the media router service.
    mMediaRouter = MediaRouter.getInstance(this);

    // Create a route selector for the type of routes that we care about.
    mSelector = new MediaRouteSelector.Builder().addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
            .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
            .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
            .addControlCategory(SampleMediaRouteProvider.CATEGORY_SAMPLE_ROUTE).build();

    // Add a fragment to take care of media route discovery.
    // This fragment automatically adds or removes a callback whenever the activity
    // is started or stopped.
    FragmentManager fm = getSupportFragmentManager();
    DiscoveryFragment fragment = (DiscoveryFragment) fm.findFragmentByTag(DISCOVERY_FRAGMENT_TAG);
    if (fragment == null) {
        fragment = new DiscoveryFragment(mMediaRouterCB);
        fragment.setRouteSelector(mSelector);
        fm.beginTransaction().add(fragment, DISCOVERY_FRAGMENT_TAG).commit();
    } else {
        fragment.setCallback(mMediaRouterCB);
        fragment.setRouteSelector(mSelector);
    }

    // Populate an array adapter with streaming media items.
    String[] mediaNames = getResources().getStringArray(R.array.media_names);
    String[] mediaUris = getResources().getStringArray(R.array.media_uris);
    mLibraryItems = new LibraryAdapter();
    for (int i = 0; i < mediaNames.length; i++) {
        mLibraryItems.add(new MediaItem("[streaming] " + mediaNames[i], Uri.parse(mediaUris[i]), "video/mp4"));
    }

    // Scan local external storage directory for media files.
    File externalDir = Environment.getExternalStorageDirectory();
    if (externalDir != null) {
        File list[] = externalDir.listFiles();
        if (list != null) {
            for (int i = 0; i < list.length; i++) {
                String filename = list[i].getName();
                if (filename.matches(".*\\.(m4v|mp4)")) {
                    mLibraryItems.add(new MediaItem("[local] " + filename, Uri.fromFile(list[i]), "video/mp4"));
                }
            }
        }
    }

    mPlayListItems = new PlaylistAdapter();

    // Initialize the layout.
    setContentView(R.layout.sample_media_router);

    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
    tabHost.setup();
    String tabName = getResources().getString(R.string.library_tab_text);
    TabSpec spec1 = tabHost.newTabSpec(tabName);
    spec1.setContent(R.id.tab1);
    spec1.setIndicator(tabName);

    tabName = getResources().getString(R.string.playlist_tab_text);
    TabSpec spec2 = tabHost.newTabSpec(tabName);
    spec2.setIndicator(tabName);
    spec2.setContent(R.id.tab2);

    tabName = getResources().getString(R.string.statistics_tab_text);
    TabSpec spec3 = tabHost.newTabSpec(tabName);
    spec3.setIndicator(tabName);
    spec3.setContent(R.id.tab3);

    tabHost.addTab(spec1);
    tabHost.addTab(spec2);
    tabHost.addTab(spec3);
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {
        @Override
        public void onTabChanged(String arg0) {
            updateUi();
        }
    });

    mLibraryView = (ListView) findViewById(R.id.media);
    mLibraryView.setAdapter(mLibraryItems);
    mLibraryView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mLibraryView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            updateButtons();
        }
    });

    mPlayListView = (ListView) findViewById(R.id.playlist);
    mPlayListView.setAdapter(mPlayListItems);
    mPlayListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mPlayListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            updateButtons();
        }
    });

    mInfoTextView = (TextView) findViewById(R.id.info);

    mPauseResumeButton = (ImageButton) findViewById(R.id.pause_resume_button);
    mPauseResumeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPaused = !mPaused;
            if (mPaused) {
                mSessionManager.pause();
            } else {
                mSessionManager.resume();
            }
        }
    });

    mStopButton = (ImageButton) findViewById(R.id.stop_button);
    mStopButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPaused = false;
            mSessionManager.stop();
        }
    });

    mSeekBar = (SeekBar) findViewById(R.id.seekbar);
    mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            PlaylistItem item = getCheckedPlaylistItem();
            if (fromUser && item != null && item.getDuration() > 0) {
                long pos = progress * item.getDuration() / 100;
                mSessionManager.seek(item.getItemId(), pos);
                item.setPosition(pos);
                item.setTimestamp(SystemClock.elapsedRealtime());
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            mSeeking = true;
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            mSeeking = false;
            updateUi();
        }
    });

    // Schedule Ui update
    mHandler.postDelayed(mUpdateSeekRunnable, 1000);

    // Build the PendingIntent for the remote control client
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mEventReceiver = new ComponentName(getPackageName(), SampleMediaButtonReceiver.class.getName());
    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setComponent(mEventReceiver);
    mMediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0);

    // Create and register the remote control client
    registerRemoteControlClient();

    // Set up playback manager and player
    mPlayer = Player.create(MainActivity.this, mMediaRouter.getSelectedRoute());
    mSessionManager.setPlayer(mPlayer);
    mSessionManager.setCallback(new SessionManager.Callback() {
        @Override
        public void onStatusChanged() {
            updateUi();
        }

        @Override
        public void onItemChanged(PlaylistItem item) {
        }
    });

    updateUi();
}

From source file:com.example.android.mediarouter.player.RadioActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Be sure to call the super class.
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mPlayer = (RadioPlayer) savedInstanceState.getSerializable("mPlayer");
    }/*from  w  w  w.  jav a2 s. c  om*/

    // Get the media router service.
    mMediaRouter = MediaRouter.getInstance(this);

    // Create a route selector for the type of routes that we care about.
    mSelector = new MediaRouteSelector.Builder().addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
            .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
            .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
            .addControlCategory(SampleMediaRouteProvider.CATEGORY_SAMPLE_ROUTE).build();

    // Add a fragment to take care of media route discovery.
    // This fragment automatically adds or removes a callback whenever the activity
    // is started or stopped.
    FragmentManager fm = getSupportFragmentManager();
    DiscoveryFragment fragment = (DiscoveryFragment) fm.findFragmentByTag(DISCOVERY_FRAGMENT_TAG);
    if (fragment == null) {
        fragment = new DiscoveryFragment(mMediaRouterCB);
        fragment.setRouteSelector(mSelector);
        fm.beginTransaction().add(fragment, DISCOVERY_FRAGMENT_TAG).commit();
    } else {
        fragment.setCallback(mMediaRouterCB);
        fragment.setRouteSelector(mSelector);
    }

    // Populate an array adapter with streaming media items.
    String[] mediaNames = getResources().getStringArray(R.array.media_names);
    String[] mediaUris = getResources().getStringArray(R.array.media_uris);
    mLibraryItems = new LibraryAdapter();
    for (int i = 0; i < mediaNames.length; i++) {
        mLibraryItems.add(new MediaItem("[streaming] " + mediaNames[i], Uri.parse(mediaUris[i]), "video/mp4"));
    }

    // Scan local external storage directory for media files.
    File externalDir = Environment.getExternalStorageDirectory();
    if (externalDir != null) {
        File list[] = externalDir.listFiles();
        if (list != null) {
            for (int i = 0; i < list.length; i++) {
                String filename = list[i].getName();
                if (filename.matches(".*\\.(m4v|mp4)")) {
                    mLibraryItems.add(new MediaItem("[local] " + filename, Uri.fromFile(list[i]), "video/mp4"));
                }
            }
        }
    }

    mPlayListItems = new PlaylistAdapter();

    // Initialize the layout.
    setContentView(R.layout.sample_radio_router);

    TabHost tabHost = (TabHost) findViewById(R.id.tabHost);
    tabHost.setup();
    String tabName = getResources().getString(R.string.library_tab_text);
    TabSpec spec1 = tabHost.newTabSpec(tabName);
    spec1.setContent(R.id.tab1);
    spec1.setIndicator(tabName);

    tabName = getResources().getString(R.string.playlist_tab_text);
    TabSpec spec2 = tabHost.newTabSpec(tabName);
    spec2.setIndicator(tabName);
    spec2.setContent(R.id.tab2);

    tabName = getResources().getString(R.string.statistics_tab_text);
    TabSpec spec3 = tabHost.newTabSpec(tabName);
    spec3.setIndicator(tabName);
    spec3.setContent(R.id.tab3);

    tabHost.addTab(spec1);
    tabHost.addTab(spec2);
    tabHost.addTab(spec3);
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {
        @Override
        public void onTabChanged(String arg0) {
            updateUi();
        }
    });

    mLibraryView = (ListView) findViewById(R.id.media);
    mLibraryView.setAdapter(mLibraryItems);
    mLibraryView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mLibraryView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            updateButtons();
        }
    });

    mPlayListView = (ListView) findViewById(R.id.playlist);
    mPlayListView.setAdapter(mPlayListItems);
    mPlayListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mPlayListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            updateButtons();
        }
    });

    mInfoTextView = (TextView) findViewById(R.id.info);

    mPauseResumeButton = (ImageButton) findViewById(R.id.pause_resume_button);
    mPauseResumeButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPaused = !mPaused;
            if (mPaused) {
                mSessionManager.pause();
            } else {
                mSessionManager.resume();
            }
        }
    });

    mStopButton = (ImageButton) findViewById(R.id.stop_button);
    mStopButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mPaused = false;
            mSessionManager.stop();
        }
    });

    mSeekBar = (SeekBar) findViewById(R.id.seekbar);
    mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            PlaylistItem item = getCheckedPlaylistItem();
            if (fromUser && item != null && item.getDuration() > 0) {
                long pos = progress * item.getDuration() / 100;
                mSessionManager.seek(item.getItemId(), pos);
                item.setPosition(pos);
                item.setTimestamp(SystemClock.elapsedRealtime());
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            mSeeking = true;
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            mSeeking = false;
            updateUi();
        }
    });

    // Schedule Ui update
    mHandler.postDelayed(mUpdateSeekRunnable, 1000);

    // Build the PendingIntent for the remote control client
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    mEventReceiver = new ComponentName(getPackageName(), SampleMediaButtonReceiver.class.getName());
    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setComponent(mEventReceiver);
    mMediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0);

    // Create and register the remote control client
    registerRemoteControlClient();

    // Set up playback manager and player
    mPlayer = RadioPlayer.create(RadioActivity.this, mMediaRouter.getSelectedRoute());
    mSessionManager.setPlayer(mPlayer);
    mSessionManager.setCallback(new RadioSessionManager.Callback() {
        @Override
        public void onStatusChanged() {
            updateUi();
        }

        @Override
        public void onItemChanged(PlaylistItem item) {
        }
    });

    updateUi();
}

From source file:com.silentcircle.contacts.group.GroupEditorFragment.java

private void onRestoreInstanceState(Bundle state) {
    mAction = state.getString(KEY_ACTION);
    mGroupUri = state.getParcelable(KEY_GROUP_URI);
    mGroupId = state.getLong(KEY_GROUP_ID);

    mStatus = (Status) state.getSerializable(KEY_STATUS);

    mGroupNameIsReadOnly = state.getBoolean(KEY_GROUP_NAME_IS_READ_ONLY);
    mOriginalGroupName = state.getString(KEY_ORIGINAL_GROUP_NAME);

    mListMembersToAdd = state.getParcelableArrayList(KEY_MEMBERS_TO_ADD);
    mListMembersToRemove = state.getParcelableArrayList(KEY_MEMBERS_TO_REMOVE);
    mListToDisplay = state.getParcelableArrayList(KEY_MEMBERS_TO_DISPLAY);
}

From source file:com.qasp.diego.arsp.MainActivity.java

@SuppressWarnings("unchecked")
@Override/*from  w  ww .  j av  a 2  s. co  m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
        // Activity was brought to front and not created,
        // Thus finishing this will get us to the last viewed activity
        finish();
        return;
    }

    // Opcoes padrao para Preferencias.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    setContentView(R.layout.activity_main);

    // Salva dados se nao for mais visivel
    if (savedInstanceState != null) {
        Global.estacoes = (ArrayList<Estacao>) savedInstanceState.getSerializable(ESTADO_ESTACOES);
        Global.GPS = (Coordenada) savedInstanceState.getSerializable(ESTADO_GPS);
    } else
        InicializaEstacoesValidas(Global.estacoes);

    // Colorizao da barra de servios.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.parseColor("#202020"));
    }

    // PERMISSOES
    verifyStoragePermissions(this);
    if (PermissaodoGPS(this)) {
        // Se a permisso ja foi aprovada anterioremente.
        Intent intent = new Intent(this, LocalizacaoGPSService.class);
        startService(intent);
    }

    // Action bar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // TABS.
    tablayout = (TabLayout) findViewById(R.id.tab_layout);
    tablayout.addTab(tablayout.newTab().setText("Lista Estaes"));
    tablayout.addTab(tablayout.newTab().setText("Indice Local"));
    tablayout.addTab(tablayout.newTab().setText("Feedback"));
    tablayout.setTabGravity(TabLayout.GRAVITY_FILL);

    // PAGER (Deslize) e Funcionamento das Tabs
    viewPager = (ViewPager) findViewById(R.id.pager);
    adapter = new PagerAdapter(getSupportFragmentManager(), tablayout.getTabCount());
    viewPager.setAdapter(adapter);
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tablayout));
    tablayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            // Notificar eventuais mudanas ao mudar de aba.
            Global.tabSelecionado = tab.getPosition();
            viewPager.setCurrentItem(tab.getPosition());
            viewPager.getAdapter().notifyDataSetChanged();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
            // vazio de proposito
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            // Vazio de proposito
        }
    });
}

From source file:com.ibuildapp.romanblack.NewsPlugin.NewsPlugin.java

@Override
public void create() {
    try {//from w  w  w.  j  ava  2 s  . com
        setContentView(R.layout.news_feed_main);
        setTitle(R.string.news_feed);
        setTopbarTitleTypeface(Typeface.NORMAL);

        mainLayout = findViewById(R.id.news_feed_main_layout);
        listView = (RecyclerView) findViewById(R.id.news_feed_main_list);
        listView.setLayoutManager(new LinearLayoutManager(this));

        progressLayout = findViewById(R.id.news_feed_main_progress_layout);
        refreshLayout = (SwipeRefreshLayout) findViewById(R.id.news_feed_main_refresh);
        refreshLayout.setEnabled(false);

        refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                loadRSS();
            }
        });

        currentIntent = getIntent();
        Bundle store = currentIntent.getExtras();
        widget = (Widget) store.getSerializable("Widget");

        if (widget == null) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100);
            return;
        }

        if (!TextUtils.isEmpty(widget.getTitle())) {
            setTopBarTitle(widget.getTitle());
        }

        setTopBarTitleColor(Color.parseColor("#000000"));

        setTopBarLeftButtonTextAndColor(getResources().getString(R.string.news_home_button),
                Color.parseColor("#000000"), true, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        finish();
                    }
                });

        try {
            if (widget.getPluginXmlData().length() == 0) {
                if (currentIntent.getStringExtra("WidgetFile").length() == 0) {
                    handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 3000);
                    return;
                }
            }
        } catch (Exception e) {
            handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 3000);
            return;
        }

        cachePath = widget.getCachePath() + "/feed-" + widget.getOrder();
        File cache = new File(this.cachePath);
        if (!cache.exists()) {
            cache.mkdirs();
        }

        // 3 seconds

        String widgetMD5 = Utils.md5(widget.getPluginXmlData());
        File cacheData = new File(cachePath + "/cache.data");
        if (cacheData.exists() && cacheData.length() > 0) {
            String cacheMD5 = readFileToString(cachePath + "/cache.md5").replace("\n", "");
            if (cacheMD5.equals(widgetMD5)) {
                useCache = true;
            } else {
                File[] files = cache.listFiles();
                for (File file : files) {
                    file.delete();
                }
                try {
                    BufferedWriter bw = new BufferedWriter(new FileWriter(new File(cachePath + "/cache.md5")));
                    bw.write(widgetMD5);
                    bw.close();
                    Log.d("IMAGES PLUGIN CACHE MD5", "SUCCESS");
                } catch (Exception e) {
                    Log.w("IMAGES PLUGIN CACHE MD5", e);
                }
            }
        }

        isOnline = NetworkUtils.isOnline(this);

        if (!isOnline && !useCache) {
            handler.sendEmptyMessage(NEED_INTERNET_CONNECTION);
            return;
        }

        new Thread() {
            @Override
            public void run() {
                timer = new Timer("EventsTimer", true);
                EntityParser parser;

                if (widget.getPluginXmlData().length() > 0) {
                    parser = new EntityParser(widget.getPluginXmlData());

                } else {
                    String xmlData = readXmlFromFile(currentIntent.getStringExtra("WidgetFile"));
                    parser = new EntityParser(xmlData);

                }

                parser.parse();

                Statics.color1 = parser.getColor1();
                Statics.color2 = parser.getColor2();
                Statics.color3 = parser.getColor3();
                Statics.color4 = parser.getColor4();
                Statics.color5 = parser.getColor5();

                handler.sendEmptyMessage(COLORS_RECEIVED);

                title = (widget.getTitle().length() > 0) ? widget.getTitle() : parser.getFuncName();
                items = parser.getItems();

                if ("rss".equals(parser.getFeedType())) {
                    Statics.isRSS = true;
                    AndroidSchedulers.mainThread().createWorker().schedule(new Action0() {
                        @Override
                        public void call() {
                            refreshLayout.setColorSchemeColors(Statics.color3);
                        }
                    });

                    feedURL = parser.getFeedUrl();
                    if (isOnline) {
                        FeedParser reader = new FeedParser(parser.getFeedUrl());
                        items = reader.parseFeed();

                        encoding = reader.getEncoding();

                        if (items.size() > 0) {
                            try {
                                ObjectOutputStream oos = new ObjectOutputStream(
                                        new FileOutputStream(cachePath + "/cache.data"));

                                oos.writeObject(items);
                                oos.flush();
                                oos.close();
                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                        }

                        Statics.isRSS = true;
                        AndroidSchedulers.mainThread().createWorker().schedule(new Action0() {
                            @Override
                            public void call() {
                                refreshLayout.setEnabled(true);
                            }
                        });
                    } else {
                        try {
                            ObjectInputStream ois = new ObjectInputStream(
                                    new FileInputStream(cachePath + "/cache.data"));
                            items = (ArrayList<FeedItem>) ois.readObject();
                            ois.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } else {
                    Statics.isRSS = false;
                    AndroidSchedulers.mainThread().createWorker().schedule(new Action0() {
                        @Override
                        public void call() {
                            refreshLayout.setEnabled(false);
                        }
                    });
                }

                for (int i = 0; i < items.size(); i++) {
                    items.get(i).setTextColor(widget.getTextColor());
                    items.get(i).setDateFormat(widget.getDateFormat());
                }

                funcName = parser.getFuncName();
                selectShowType();
            }
        }.start();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.bukanir.android.activities.MoviesListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);

    if (!LibsChecker.checkVitamioLibs(this)) {
        return;/* www .  j  a  v  a  2s.c  o m*/
    }

    if (!Utils.isHttpServiceRunning(this)) {
        Intent intent = new Intent(this, BukanirHttpService.class);
        startService(intent);
    }

    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.activity_movie_list);

    if (findViewById(R.id.movie_container) != null) {
        twoPane = true;
    } else {
        twoPane = false;
    }

    if (savedInstanceState != null) {
        movies = (ArrayList<Movie>) savedInstanceState.getSerializable("movies");
    }

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    Boolean eulaAccepted = prefs.getBoolean("eula_accepted", false);

    if (!eulaAccepted) {
        new EulaFragment().show(getSupportFragmentManager(), "Eula");
    } else {
        prepareActionBar();
    }
}

From source file:com.xujian.bizProduct.mvp1.ui.TasksActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(0);/*from w ww  .  jav  a 2 s  . com*/

    // Set up the navigation drawer.
    mDrawerLayout = (DrawerLayout) findViewById(0);
    mDrawerLayout.setStatusBarBackground(0);
    NavigationView navigationView = (NavigationView) findViewById(0);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }

    TasksFragment tasksFragment = (TasksFragment) getSupportFragmentManager().findFragmentById(0);
    if (tasksFragment == null) {
        // Create the fragment
        tasksFragment = TasksFragment.newInstance();
        ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), tasksFragment, 0);
    }

    // Create the presenter
    mTasksPresenter = new TasksPresenter(null, tasksFragment, null);

    // Load previously saved state, if available.
    if (savedInstanceState != null) {
        TasksFilterType currentFiltering = (TasksFilterType) savedInstanceState
                .getSerializable(CURRENT_FILTERING_KEY);
        mTasksPresenter.setFiltering(currentFiltering);
    }
}

From source file:de.eidottermihi.rpicheck.activity.MainActivity.java

@Override
protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState.getSerializable(CURRENT_DEVICE) != null) {
        LOGGER.debug("Restoring device..");
        currentDevice = (RaspberryDeviceBean) savedInstanceState.getSerializable(CURRENT_DEVICE);
        // restoring tables
        LOGGER.debug("Setting spinner to show last Pi.");
        this.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
        this.getSupportActionBar().setSelectedNavigationItem(currentDevice.getSpinnerPosition());
        if (currentDevice.getLastQueryData() != null
                && currentDevice.getLastQueryData().getException() == null) {
            LOGGER.debug("Restoring query data..");
            this.updateQueryDataInView(currentDevice.getLastQueryData());
        } else {//from   w w w .j  a va  2 s  .c  om
            LOGGER.debug("No last query data present.");
            this.resetView();
        }
    }
    if (savedInstanceState.getSparseParcelableArray(ALL_DEVICES) != null) {
        LOGGER.debug("Restoring all devices.");
        allDevices = savedInstanceState.getSparseParcelableArray(ALL_DEVICES);
    }
}

From source file:com.example.rps.RpsFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        wins = savedInstanceState.getInt(WIN_KEY);
        losses = savedInstanceState.getInt(LOSS_KEY);
        ties = savedInstanceState.getInt(TIE_KEY);
        computerChoice = savedInstanceState.getInt(COMPUTER_CHOICE_KEY);
        playerChoice = savedInstanceState.getInt(PLAYER_CHOICE_KEY);
        currentState = (RpsState) savedInstanceState.getSerializable(STATE_KEY);
        result = (RpsResult) savedInstanceState.getSerializable(RESULT_KEY);
        pendingPublish = savedInstanceState.getBoolean(PENDING_PUBLISH_KEY);
        shouldImplicitlyPublish = savedInstanceState.getBoolean(IMPLICIT_PUBLISH_KEY);
    }// w  w  w .ja  v  a2 s  . c o m
    callbackManager = CallbackManager.Factory.create();
    LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
        @Override
        public void onSuccess(LoginResult loginResult) {
            AccessToken accessToken = AccessToken.getCurrentAccessToken();
            if (accessToken.getPermissions().contains(ADDITIONAL_PERMISSIONS)) {
                publishResult();
            } else {
                handleError();
            }
        }

        @Override
        public void onCancel() {
            handleError();
        }

        @Override
        public void onError(FacebookException exception) {
            handleError();
        }

        private void handleError() {
            // this means the user did not grant us write permissions, so
            // we don't do implicit publishes
            shouldImplicitlyPublish = false;
            pendingPublish = false;
        }
    });

    FacebookCallback<Sharer.Result> callback = new FacebookCallback<Sharer.Result>() {
        @Override
        public void onCancel() {
            Log.d(TAG, "Canceled");
        }

        @Override
        public void onError(FacebookException error) {
            Log.d(TAG, String.format("Error: %s", error.toString()));
        }

        @Override
        public void onSuccess(Sharer.Result result) {
            Log.d(TAG, "Success!");
        }
    };
    shareDialog = new ShareDialog(this);
    shareDialog.registerCallback(callbackManager, callback);
    messageDialog = new MessageDialog(this);
    messageDialog.registerCallback(callbackManager, callback);

    FacebookCallback<AppInviteDialog.Result> appInviteCallback = new FacebookCallback<AppInviteDialog.Result>() {
        @Override
        public void onSuccess(AppInviteDialog.Result result) {
            Log.d(TAG, "Success!");
        }

        @Override
        public void onCancel() {
            Log.d(TAG, "Canceled");
        }

        @Override
        public void onError(FacebookException error) {
            Log.d(TAG, String.format("Error: %s", error.toString()));
        }
    };
    appInviteDialog = new AppInviteDialog(this);
    appInviteDialog.registerCallback(callbackManager, appInviteCallback);
}

From source file:aarddict.android.ArticleViewActivity.java

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override//from   w  ww .  j a v a  2 s  .c  om
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    backItems = Collections.synchronizedList((List) savedInstanceState.getSerializable("backItems"));
    scrollPositionsH = Collections
            .synchronizedMap((Map) savedInstanceState.getSerializable("scrollPositionsH"));
    scrollPositionsV = Collections
            .synchronizedMap((Map) savedInstanceState.getSerializable("scrollPositionsV"));
}