Example usage for android.os Bundle getInt

List of usage examples for android.os Bundle getInt

Introduction

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

Prototype

public int getInt(String key) 

Source Link

Document

Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.

Usage

From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java

@Nullable
@Override/*from  www  .  j a v a 2s  .  co m*/
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    resolveTheme();
    LayoutInflater localInflater = getThemeInflater(inflater);
    final ViewGroup view = (ViewGroup) localInflater.inflate(R.layout.lb_onboarding_fragment, container, false);
    mIsLtr = getResources().getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
    mPageIndicator = (PagingIndicator) view.findViewById(R.id.page_indicator);
    mPageIndicator.setOnClickListener(mOnClickListener);
    mPageIndicator.setOnKeyListener(mOnKeyListener);
    mStartButton = view.findViewById(R.id.button_start);
    mStartButton.setOnClickListener(mOnClickListener);
    mStartButton.setOnKeyListener(mOnKeyListener);
    mLogoView = (ImageView) view.findViewById(R.id.logo);
    mTitleView = (TextView) view.findViewById(R.id.title);
    mDescriptionView = (TextView) view.findViewById(R.id.description);
    if (sSlideDistance == 0) {
        sSlideDistance = (int) (SLIDE_DISTANCE
                * getActivity().getResources().getDisplayMetrics().scaledDensity);
    }
    if (savedInstanceState == null) {
        mCurrentPageIndex = 0;
        mEnterTransitionFinished = false;
        mPageIndicator.onPageSelected(0, false);
        view.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                view.getViewTreeObserver().removeOnPreDrawListener(this);
                if (!startLogoAnimation()) {
                    startEnterAnimation();
                }
                return true;
            }
        });
    } else {
        mEnterTransitionFinished = true;
        mCurrentPageIndex = savedInstanceState.getInt(KEY_CURRENT_PAGE_INDEX);
        initializeViews(view);
    }
    view.requestFocus();
    return view;
}

From source file:mobisocial.musubi.ui.fragments.FeedViewFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mInputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    mObserver = new ContentObserver(new Handler(mActivity.getMainLooper())) {
        @Override/* w  w  w .  jav a  2 s .c o m*/
        public void onChange(boolean selfChange) {
            if (mObjects == null || mObjects.getCursor() == null || !isAdded()) {
                return;
            }

            // XXX Move this to WizardStepHandler-- register a content observer
            // there only when required.
            if (WizardStepHandler.isCurrentTask(mActivity, WizardStepHandler.TASK_EDIT_PICTURE)) {
                Cursor c = mObjects.getCursor();
                ObjectManager om = new ObjectManager(App.getDatabaseSource(mActivity));
                AppManager am = new AppManager(App.getDatabaseSource(mActivity));
                if (c.moveToFirst()) {
                    while (!c.isAfterLast()) {
                        long objId = c.getLong(c.getColumnIndexOrThrow(MObject.COL_ID));
                        MObject obj = om.getObjectForId(objId);
                        if (obj != null && am.getAppIdentifier(obj.appId_).startsWith("musubi.sketch")) {
                            WizardStepHandler.accomplishTask(mActivity, WizardStepHandler.TASK_EDIT_PICTURE);
                            break;
                        }
                        c.moveToNext();
                    }
                }
            }

            if (DBG)
                Log.d(TAG, "-- contentObserver observed change");
            getLoaderManager().restartLoader(0, getLoaderArgs(mTotal), FeedViewFragment.this);
        }
    };

    if (savedInstanceState != null) {
        mTotal = savedInstanceState.getInt(EXTRA_NUM_ITEMS);
        Log.d(TAG, "setting total from instance: " + mTotal);
    } else {
        Log.d(TAG, "using total " + mTotal);
    }

    if (DBG)
        Log.d(TAG, "-- onCreated");
    getLoaderManager().initLoader(0, getLoaderArgs(mTotal), this);
}

From source file:com.google.sample.castcompanionlibrary.utils.Utils.java

/**
 * Builds and returns a {@link MediaInfo} that was wrapped in a {@link Bundle} by
 * <code>fromMediaInfo</code>.
 *
 * @param wrapper//from  ww  w  .j  a va2 s. c  o m
 * @return
 * @see <code>fromMediaInfo()</code>
 */
public static MediaInfo toMediaInfo(Bundle wrapper) {
    if (null == wrapper) {
        return null;
    }

    MediaMetadata metaData = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);

    metaData.putString(MediaMetadata.KEY_SUBTITLE, wrapper.getString(MediaMetadata.KEY_SUBTITLE));
    metaData.putString(MediaMetadata.KEY_TITLE, wrapper.getString(MediaMetadata.KEY_TITLE));
    metaData.putString(MediaMetadata.KEY_STUDIO, wrapper.getString(MediaMetadata.KEY_STUDIO));
    ArrayList<String> images = wrapper.getStringArrayList(KEY_IMAGES);
    if (null != images && !images.isEmpty()) {
        for (String url : images) {
            Uri uri = Uri.parse(url);
            metaData.addImage(new WebImage(uri));
        }
    }
    String customDataStr = wrapper.getString(KEY_CUSTOM_DATA);
    JSONObject customData = null;
    if (!TextUtils.isEmpty(customDataStr)) {
        try {
            customData = new JSONObject(customDataStr);
        } catch (JSONException e) {
            LOGE(TAG, "Failed to deserialize the custom data string: custom data= " + customDataStr);
        }
    }
    List<MediaTrack> mediaTracks = null;
    if (wrapper.getString(KEY_TRACKS_DATA) != null) {
        try {
            JSONArray jsonArray = new JSONArray(wrapper.getString(KEY_TRACKS_DATA));
            mediaTracks = new ArrayList<MediaTrack>();
            if (jsonArray != null && jsonArray.length() > 0) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObj = (JSONObject) jsonArray.get(i);
                    MediaTrack.Builder builder = new MediaTrack.Builder(jsonObj.getLong(KEY_TRACK_ID),
                            jsonObj.getInt(KEY_TRACK_TYPE));
                    if (jsonObj.has(KEY_TRACK_NAME)) {
                        builder.setName(jsonObj.getString(KEY_TRACK_NAME));
                    }
                    if (jsonObj.has(KEY_TRACK_SUBTYPE)) {
                        builder.setSubtype(jsonObj.getInt(KEY_TRACK_SUBTYPE));
                    }
                    if (jsonObj.has(KEY_TRACK_CONTENT_ID)) {
                        builder.setContentId(jsonObj.getString(KEY_TRACK_CONTENT_ID));
                    }
                    if (jsonObj.has(KEY_TRACK_LANGUAGE)) {
                        builder.setLanguage(jsonObj.getString(KEY_TRACK_LANGUAGE));
                    }
                    if (jsonObj.has(KEY_TRACKS_DATA)) {
                        builder.setCustomData(new JSONObject(jsonObj.getString(KEY_TRACKS_DATA)));
                    }
                    mediaTracks.add(builder.build());
                }
            }
        } catch (JSONException e) {
            LOGE(TAG, "Failed to build media tracks from the wrapper bundle", e);
        }
    }
    return new MediaInfo.Builder(wrapper.getString(KEY_URL)).setStreamType(wrapper.getInt(KEY_STREAM_TYPE))
            .setContentType(wrapper.getString(KEY_CONTENT_TYPE)).setMetadata(metaData).setCustomData(customData)
            .setMediaTracks(mediaTracks).setStreamDuration(wrapper.getLong(KEY_STREAM_DURATION)).build();
}

From source file:com.andrewshu.android.reddit.threads.ThreadsListActivity.java

/**
 * Called when the activity starts up. Do activity initialization
 * here, not in a constructor.//  w w  w .  j av  a  2  s  .  co m
 * 
 * @see Activity#onCreate
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CookieSyncManager.createInstance(getApplicationContext());

    mSettings.loadRedditPreferences(getApplicationContext(), mClient);
    setRequestedOrientation(mSettings.getRotation());
    setTheme(mSettings.getTheme());
    requestWindowFeature(Window.FEATURE_PROGRESS);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.threads_list_content);
    registerForContextMenu(getListView());

    if (savedInstanceState != null) {
        if (Constants.LOGGING)
            Log.d(TAG, "using savedInstanceState");
        mSubreddit = savedInstanceState.getString(Constants.SUBREDDIT_KEY);
        if (mSubreddit == null)
            mSubreddit = mSettings.getHomepage();
        mAfter = savedInstanceState.getString(Constants.AFTER_KEY);
        mBefore = savedInstanceState.getString(Constants.BEFORE_KEY);
        mCount = savedInstanceState.getInt(Constants.THREAD_COUNT_KEY);
        mLastAfter = savedInstanceState.getString(Constants.LAST_AFTER_KEY);
        mLastBefore = savedInstanceState.getString(Constants.LAST_BEFORE_KEY);
        mLastCount = savedInstanceState.getInt(Constants.THREAD_LAST_COUNT_KEY);
        mSortByUrl = savedInstanceState.getString(Constants.ThreadsSort.SORT_BY_KEY);
        mJumpToThreadId = savedInstanceState.getString(Constants.JUMP_TO_THREAD_ID_KEY);
        mVoteTargetThing = savedInstanceState.getParcelable(Constants.VOTE_TARGET_THING_INFO_KEY);

        // try to restore mThreadsList using getLastNonConfigurationInstance()
        // (separate function to avoid a compiler warning casting ArrayList<ThingInfo>
        restoreLastNonConfigurationInstance();
        if (mThreadsList == null) {
            // Load previous view of threads
            if (mLastAfter != null) {
                new MyDownloadThreadsTask(mSubreddit, mLastAfter, null, mLastCount).execute();
            } else if (mLastBefore != null) {
                new MyDownloadThreadsTask(mSubreddit, null, mLastBefore, mLastCount).execute();
            } else {
                new MyDownloadThreadsTask(mSubreddit).execute();
            }
        } else {
            // Orientation change. Use prior instance.
            resetUI(new ThreadsListAdapter(this, mThreadsList));
            if (Constants.FRONTPAGE_STRING.equals(mSubreddit))
                setTitle("reddit.com: what's new online!");
            else
                setTitle("/r/" + mSubreddit.trim());
        }
    }
    // Handle subreddit Uri passed via Intent
    else if (getIntent().getData() != null) {
        Matcher redditContextMatcher = REDDIT_PATH_PATTERN.matcher(getIntent().getData().getPath());
        if (redditContextMatcher.matches()) {
            new MyDownloadThreadsTask(redditContextMatcher.group(1)).execute();
        } else {
            new MyDownloadThreadsTask(mSettings.getHomepage()).execute();
        }
    }
    // No subreddit specified by Intent, so load the user's home reddit
    else {
        new MyDownloadThreadsTask(mSettings.getHomepage()).execute();
    }
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.ZipFlashingFragment.java

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

    if (savedInstanceState != null) {
        ArrayList<PendingAction> savedActions = savedInstanceState
                .getParcelableArrayList(EXTRA_PENDING_ACTIONS);
        mPendingActions.addAll(savedActions);
    }/*from  w  w w . j  ava2s.  c o m*/

    mProgressBar = (ProgressBar) getActivity().findViewById(R.id.card_list_loading);
    RecyclerView cardListView = (RecyclerView) getActivity().findViewById(R.id.card_list);

    mAdapter = new PendingActionCardAdapter(getActivity(), mPendingActions);
    cardListView.setHasFixedSize(true);
    cardListView.setAdapter(mAdapter);

    DragSwipeItemTouchCallback itemTouchCallback = new DragSwipeItemTouchCallback(this);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchCallback);
    itemTouchHelper.attachToRecyclerView(cardListView);

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

    AddFloatingActionButton fabFlashZip = (AddFloatingActionButton) getActivity()
            .findViewById(R.id.fab_add_zip);
    fabFlashZip.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            // Show file chooser
            Intent intent = FileUtils.getFileOpenIntent(getActivity());
            startActivityForResult(intent, ACTIVITY_REQUEST_FILE);
        }
    });

    if (savedInstanceState != null) {
        mSelectedFile = savedInstanceState.getString(EXTRA_SELECTED_FILE);
        mSelectedRomId = savedInstanceState.getString(EXTRA_SELECTED_ROM_ID);
        mZipRomId = savedInstanceState.getString(EXTRA_ZIP_ROM_ID);
        mTaskIdVerifyZip = savedInstanceState.getInt(EXTRA_TASK_ID_VERIFY_ZIP);
    }

    try {
        mActivityCallback = (OnReadyStateChangedListener) getActivity();
    } catch (ClassCastException e) {
        throw new ClassCastException(getActivity().toString() + " must implement OnReadyStateChangedListener");
    }

    mActivityCallback.onReady(!mPendingActions.isEmpty());

    mPrefs = getActivity().getSharedPreferences("settings", 0);

    if (savedInstanceState == null) {
        boolean shouldShow = mPrefs.getBoolean(PREF_SHOW_FIRST_USE_DIALOG, true);
        if (shouldShow) {
            FirstUseDialog d = FirstUseDialog.newInstance(this, R.string.zip_flashing_title,
                    R.string.zip_flashing_dialog_first_use);
            d.show(getFragmentManager(), CONFIRM_DIALOG_FIRST_USE);
        }
    }

    getActivity().getLoaderManager().initLoader(0, null, this);
}

From source file:at.alladin.rmbt.android.main.RMBTMainActivity.java

@SuppressWarnings("unchecked")
protected void restoreInstance(Bundle b) {
    if (b == null)
        return;//from   www  .ja v a2  s  .  co m
    historyFilterDevices = (String[]) b.getSerializable("historyFilterDevices");
    historyFilterNetworks = (String[]) b.getSerializable("historyFilterNetworks");
    historyFilterDevicesFilter = (ArrayList<String>) b.getSerializable("historyFilterDevicesFilter");
    historyFilterNetworksFilter = (ArrayList<String>) b.getSerializable("historyFilterNetworksFilter");
    historyItemList.clear();
    historyItemList.addAll((ArrayList<Map<String, String>>) b.getSerializable("historyItemList"));
    historyStorageList.clear();
    historyStorageList.addAll((ArrayList<Map<String, String>>) b.getSerializable("historyStorageList"));
    historyResultLimit = b.getInt("historyResultLimit");
    currentMapOptions.clear();
    currentMapOptions.putAll((HashMap<String, String>) b.getSerializable("currentMapOptions"));
    currentMapOptionTitles = (HashMap<String, String>) b.getSerializable("currentMapOptionTitles");
    mapTypeListSectionList = (ArrayList<MapListSection>) b.getSerializable("mapTypeListSectionList");
    mapFilterListSectionListMap = (HashMap<String, List<MapListSection>>) b
            .getSerializable("mapFilterListSectionListMap");
    currentMapType = (MapListEntry) b.getSerializable("currentMapType");
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

/** register boradcast*/
private void registerBoradcast() {
    IntentFilter intentfilter = new IntentFilter();
    intentfilter.addAction(Constants.RECEIVER_BROADCAST);
    intentfilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
    intentfilter.addAction(Intent.ACTION_SCREEN_OFF);
    intentfilter.addAction(Intent.ACTION_SCREEN_ON);
    boradcastListener = new BroadcastReceiver() {
        @Override//from w  ww .  j av  a 2 s  . co  m
        public void onReceive(Context context, Intent intent) {

            DebugLog.d(TAG, "WebViewActivity onReceive");
            DebugLog.e(TAG, "BroadcastReceiver action = " + intent.getAction());
            if (intent.getAction().equalsIgnoreCase(Constants.RECEIVER_BROADCAST)) {
                Bundle bundle = intent.getExtras();
                int msgtype = bundle.getInt("msgtype");
                String msgcontent = bundle.getString("msgcontent");
                DebugLog.d(TAG, "handleMessage...... msgtype=" + msgtype + ", msgcontent=" + msgcontent);
                switch (msgtype) {
                case NotifyManagement.UP_PROBE_BAD_NETWORK:
                    //irtsp 1.12 , WebBrowser is not need to handler the UP_PROBE_BAD_NETWORK event message.
                    /*DebugLog.d(TAG, "UP_PROBE_BAD_NETWORK");
                    mPoorProbingresultFlag = true;
                    mPlayer.bitrate_stopProbe();
                    notifyProbingCompleted(true);*/
                    break;
                case NotifyManagement.UP_PROBE_EXIT:// callback disconnectCB = 6 when bandwidth probe
                    // success. Up_ui_gc.h
                    DebugLog.d(TAG, "GameActivity.m_player.bitrate_stopProbe()");
                    //notifyProbingCompleted(true);
                    /*if(bExitWaitProbeDone){
                       new Timer().schedule(new LogoutTimer(), 100);
                    }*/
                    break;
                case NotifyManagement.UP_PROBE_EXIT_FAIL:// callback disconnectCB = 10 when bandwidth probe
                    // fail. Up_ui_gc.h
                    DebugLog.d(TAG,
                            "WebViewActivity.onStart() probe fail, GameActivity.m_player.bitrate_stopProbe()");
                    //mPlayer.bitrate_stopProbe();
                    notifyProbingCompleted(false);
                    /*if(bExitWaitProbeDone){
                       new Timer().schedule(new LogoutTimer(), 100);
                    }*/
                    break;
                case NotifyManagement.UP_GAME_NOTIFY_DISPLAYTEXT:
                    DebugLog.d(TAG, "notify UP_GAME_NOTIFY_DISPLAYTEXT");
                    gBNotifyDisplayExit = true;
                    gNotifyDisplayText = msgcontent;

                    break;
                case NotifyManagement.LOCAL_BROADCAST_CALL_UPDATE_STATE_200:
                    callJsUpdateStatus(Constants.RESPONSE_200);
                    break;

                case NotifyManagement.LOCAL_NOTIFY_WEBJS_GET_DUI:
                    String gid = bundle.getString("gid");
                    String useragent = bundle.getString("useragent");
                    DebugLog.d(TAG, "notify webview js get DUI gid=" + gid + ",useragent=" + useragent);
                    setToJsPlayMetadata(gid, useragent);
                    break;
                case NotifyManagement.LOCAL_GAMEACTIVITY_RESULT:
                    DebugLog.d(TAG, "Constants.LOCAL_GAMEACTIVITY_RESULT");
                    ((LoadWebJsActivity) mWebviewActivity).handleGameActivityResult();
                    break;

                case NotifyManagement.CAST_SESSION_STATUS_WEB:
                    DebugLog.d(TAG, "build session have done");

                    String deviceId;
                    String deviceName;
                    String status;

                    deviceId = bundle.getString("deviceId");
                    deviceName = bundle.getString("deviceName");
                    status = bundle.getString("status");
                    retPlayOnCast(deviceId, deviceName, status);

                    synchronized (mLock) {
                        mLock.notify();
                        DebugLog.d(TAG, "notify the thread");
                    }

                    break;
                }
            } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                processNetworkType(intent, context);
            }

            if (intent.getAction().compareTo(Intent.ACTION_SCREEN_OFF) == 0) {
                DebugLog.d(TAG, "POWER ACTION_SCREEN_OFF");
                final LoadWebJsActivity loadWebJsActivity = (LoadWebJsActivity) mContext;
                loadWebJsActivity.gBEntryPowerKeyMode = true;
                loadWebJsActivity.gCurEntryBackgroundTime = System.currentTimeMillis();
            } else if (intent.getAction().compareTo(Intent.ACTION_SCREEN_ON) == 0) {
                DebugLog.d(TAG, "POWER ACTION_SCREEN_ON");
                final LoadWebJsActivity loadWebJsActivity = (LoadWebJsActivity) mContext;
                loadWebJsActivity.gBEntryPowerKeyMode = false;
                //   loadWebJsActivity.gCurEntryBackgroundTime = 0;

            }
        }
    };
    this.mContext.registerReceiver(boradcastListener, intentfilter);
}

From source file:cgeo.geocaching.CacheListActivity.java

@Override
public Loader<SearchResult> onCreateLoader(final int type, final Bundle extras) {
    if (type >= CacheListLoaderType.values().length) {
        throw new IllegalArgumentException("invalid loader type " + type);
    }// w  ww . j  av  a2s.c  o m
    final CacheListLoaderType enumType = CacheListLoaderType.values()[type];
    AbstractSearchLoader loader = null;
    switch (enumType) {
    case OFFLINE:
        // open either the requested or the last list
        if (extras.containsKey(Intents.EXTRA_LIST_ID)) {
            listId = extras.getInt(Intents.EXTRA_LIST_ID);
        } else {
            listId = Settings.getLastDisplayedList();
        }
        if (listId == PseudoList.ALL_LIST.id) {
            title = res.getString(R.string.list_all_lists);
        } else if (listId <= StoredList.TEMPORARY_LIST.id) {
            listId = StoredList.STANDARD_LIST_ID;
            title = res.getString(R.string.stored_caches_button);
        } else {
            final StoredList list = DataStore.getList(listId);
            // list.id may be different if listId was not valid
            if (list.id != listId) {
                showToast(getString(R.string.list_not_available));
            }
            listId = list.id;
            title = list.title;
        }

        loader = new OfflineGeocacheListLoader(this, coords, listId);

        break;
    case HISTORY:
        title = res.getString(R.string.caches_history);
        listId = PseudoList.HISTORY_LIST.id;
        loader = new HistoryGeocacheListLoader(this, coords);
        break;
    case NEAREST:
        title = res.getString(R.string.caches_nearby);
        loader = new CoordsGeocacheListLoader(this, coords);
        break;
    case COORDINATE:
        title = coords.toString();
        loader = new CoordsGeocacheListLoader(this, coords);
        break;
    case KEYWORD:
        final String keyword = extras.getString(Intents.EXTRA_KEYWORD);
        title = listNameMemento.rememberTerm(keyword);
        if (keyword != null) {
            loader = new KeywordGeocacheListLoader(this, keyword);
        }
        break;
    case ADDRESS:
        final String address = extras.getString(Intents.EXTRA_ADDRESS);
        if (StringUtils.isNotBlank(address)) {
            title = listNameMemento.rememberTerm(address);
        } else {
            title = coords.toString();
        }
        loader = new CoordsGeocacheListLoader(this, coords);
        break;
    case FINDER:
        final String username = extras.getString(Intents.EXTRA_USERNAME);
        title = listNameMemento.rememberTerm(username);
        if (username != null) {
            loader = new FinderGeocacheListLoader(this, username);
        }
        break;
    case OWNER:
        final String ownerName = extras.getString(Intents.EXTRA_USERNAME);
        title = listNameMemento.rememberTerm(ownerName);
        if (ownerName != null) {
            loader = new OwnerGeocacheListLoader(this, ownerName);
        }
        break;
    case MAP:
        //TODO Build Null loader
        title = res.getString(R.string.map_map);
        search = (SearchResult) extras.get(Intents.EXTRA_SEARCH);
        replaceCacheListFromSearch();
        loadCachesHandler.sendMessage(Message.obtain());
        break;
    case NEXT_PAGE:
        loader = new NextPageGeocacheListLoader(this, search);
        break;
    case POCKET:
        final String guid = extras.getString(Intents.EXTRA_POCKET_GUID);
        title = listNameMemento.rememberTerm(extras.getString(Intents.EXTRA_NAME));
        loader = new PocketGeocacheListLoader(this, guid);
        break;
    }
    // if there is a title given in the activity start request, use this one instead of the default
    if (extras != null && StringUtils.isNotBlank(extras.getString(Intents.EXTRA_TITLE))) {
        title = extras.getString(Intents.EXTRA_TITLE);
    }
    if (loader != null && extras != null && extras.getSerializable(BUNDLE_ACTION_KEY) != null) {
        final AfterLoadAction action = (AfterLoadAction) extras.getSerializable(BUNDLE_ACTION_KEY);
        loader.setAfterLoadAction(action);
    }
    updateTitle();
    showProgress(true);
    showFooterLoadingCaches();

    return loader;
}

From source file:es.uniovi.imovil.fcrtrainer.HexadecimalExerciseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

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

    etAnswer = (EditText) rootView.findViewById(R.id.answer);
    bChange = (Button) rootView.findViewById(R.id.change);
    bSolution = (Button) rootView.findViewById(R.id.seesolution);
    bCheck = (Button) rootView.findViewById(R.id.checkbutton);
    tvNumberToConvert = (TextView) rootView.findViewById(R.id.numbertoconvert);
    tvTitle = (TextView) rootView.findViewById(R.id.exercisetitle);
    tvPoints = (TextView) rootView.findViewById(R.id.tvpoints);
    randomGenerator = new Random();

    etAnswer.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (EditorInfo.IME_ACTION_DONE == actionId) {
                if (tohex)
                    isCorrect(etAnswer.getEditableText().toString().trim().toLowerCase(Locale.US));
                else
                    isCorrect(etAnswer.getEditableText().toString().trim());
            }
            return false;
        }
    });

    bCheck.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (tohex)
                isCorrect(etAnswer.getEditableText().toString().trim().toLowerCase(Locale.US));
            else
                isCorrect(etAnswer.getEditableText().toString().trim());
        }
    });

    bChange.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            tohex ^= true;
            if (tohex) {
                setKeyboardLayout();
                setTitle();
            } else {
                setKeyboardLayout();
                setTitle();
            }
            generateRandomNumber();
        }
    });

    bSolution.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            showSolution();
        }
    });

    if (savedInstanceState != null) {
        tohex = savedInstanceState.getBoolean("tohex");
        numberToConvert = savedInstanceState.getInt("numbertoconvert");
        updateUI();
        setKeyboardLayout();
        setTitle();
    } else
        generateRandomNumber();

    return rootView;
}

From source file:com.hybris.mobile.lib.commerce.sync.CatalogSyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {/*ww  w. jav  a  2  s  .  com*/

    Log.i(TAG, "Receiving a sync with bundle: " + extras.toString());

    // Get some optional parameters
    String categoryId = extras.getString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID);
    String productId = extras.getString(CatalogSyncConstants.SYNC_PARAM_DATA_ID);
    boolean loadVariants = extras.getBoolean(CatalogSyncConstants.SYNC_PARAM_LOAD_VARIANTS);
    String contentServiceHelperUrl = extras
            .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_URL);
    boolean cancelAllRequests = extras.getBoolean(CatalogSyncConstants.SYNC_PARAM_CANCEL_ALL_REQUESTS);

    // Update the content service helper url
    if (StringUtils.isNotBlank(contentServiceHelperUrl)) {
        String catalog = extras.getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG);
        String catalogId = extras.getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG_ID);
        String catalogVersionId = extras
                .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_CATALOG_VERSION_ID);
        String catalogMainCategoryId = extras
                .getString(CatalogSyncConstants.SYNC_PARAM_CONTENT_SERVICE_HELPER_MAIN_CATEGORY_ID);
        updateContentServiceHelperUrlConfiguration(contentServiceHelperUrl, catalog, catalogId,
                catalogVersionId, catalogMainCategoryId);
    }
    // Cancelling all the requests
    else if (cancelAllRequests) {
        cancelAllRequests();
    }
    // Sync a category
    else if (StringUtils.isNotBlank(categoryId)) {
        Log.i(TAG, "Syncing the category " + categoryId);

        int currentPage = 0;
        int pageSize = 0;

        if (extras.containsKey(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE)
                && extras.containsKey(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE)) {
            currentPage = extras.getInt(CatalogSyncConstants.SYNC_PARAM_CURRENT_PAGE);
            pageSize = extras.getInt(CatalogSyncConstants.SYNC_PARAM_PAGE_SIZE);
        }

        syncCategory(categoryId, currentPage, pageSize);

    }
    // Sync a product
    else if (StringUtils.isNotBlank(productId)) {
        Log.i(TAG, "Syncing the product " + productId);

        loadProduct(productId, categoryId, null, false, loadVariants);
    }
    // Sync all the catalog
    else {
        Log.i(TAG, "Syncing the catalog");

        // Init nb calls counter and blocker
        mNbCalls = new AtomicInteger();
        mBlockSync = new CountDownLatch(1);

        String categories = extras.getString(CatalogSyncConstants.SYNC_PARAM_GROUP_ID_LIST);

        try {
            String[] categoryList = null;

            if (StringUtils.isNotBlank(categories)) {
                categoryList = categories.split(CatalogSyncConstants.SYNC_PARAM_GROUP_ID_LIST_SEPARATOR);
            }

            syncCatalog(categoryList);

            // Save the date
            mContentServiceHelper.saveCatalogLastSyncDate(new Date().getTime());

            // Showing the notification
            showNotificationProgress(true);

            // Wait for the end of the sync
            mBlockSync.await(getContext().getResources().getInteger(R.integer.sync_timeout_in_min),
                    TimeUnit.MINUTES);

        } catch (InterruptedException e) {
            Log.e(TAG, "Error syncing the catalog");
        }
    }
}