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:com.chatwing.whitelabel.activities.CommunicationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ChatWing.instance(getApplicationContext()).getChatwingGraph().plus();

    setContentView(R.layout.activity_communication);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);// w w  w .ja  va 2s. co  m

    getSupportActionBar().setHomeButtonEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp);

    mBus.register(this);

    mContentView = findViewById(R.id.fragment_container);
    mProgressView = findViewById(R.id.progress_container);
    mProgressBar = (ProgressBar) mProgressView.findViewById(R.id.loading_view);
    mProgressText = (TextView) mProgressView.findViewById(R.id.progress_text);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mLoadingView = (ProgressBar) findViewById(R.id.progress_bar);

    mNewMessageSoundId = getSoundNewMessageId();

    mChatboxModeManager.onCreate(savedInstanceState);
    mConversationModeManager.onCreate(savedInstanceState);

    stopRefreshAnimation();

    //This mode is priority due to user action requesting open
    int actionMode = getActionMode(getIntent());
    LogUtils.v("Intent to use actionMode mode " + actionMode);

    int pauseSavedMode = mCommunicationActivityManager.getInt(R.string.current_mode_state, 0);
    int currentMode = MODE_CHAT_BOX; //Default mode is chatbox

    if (pauseSavedMode != 0) {
        currentMode = pauseSavedMode;
    }

    if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_CURRENT_MODE)) {
        currentMode = savedInstanceState.getInt(EXTRA_CURRENT_MODE);
    }

    //Override current mode by priority mode
    if (actionMode != MODE_NONE) {
        currentMode = actionMode;
    }

    if (currentMode == MODE_CHAT_BOX) {
        setupChatboxMode();
    } else {
        setupConversationMode();
    }

    mIsCreated = true;

    String action = getIntent().getAction();
    if (ACTION_STOP_MEDIA.equals(action)) {
        startService(new Intent(MusicService.ACTION_STOP));
    }

    if (!mBuildManager.isOfficialChatWingApp() && userManager.getCurrentUser() == null) {
        startActivity(new Intent(this, WhiteLabelCoverActivity.class));
        finish();
        return;
    }

    String onlineFragmentTag = getString(R.string.fragment_tag_online_user);
    if (getSupportFragmentManager().findFragmentByTag(onlineFragmentTag) == null) {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.right_drawer_container, new OnlineUsersFragment(), onlineFragmentTag);
        fragmentTransaction.commit();
    }

    String adsFragmentTag = getString(R.string.fragment_tag_ads);
    if (mBuildManager.isSupportedAds()
            && getSupportFragmentManager().findFragmentByTag(adsFragmentTag) == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.ads_container, new AdFragment(), adsFragmentTag)
                .commit();
    }

    //We start our lovely ChatService so that it listen to faye server
    startService(new Intent(this, ChatWingChatService.class));
}

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

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

    if (savedInstanceState != null) {
        ArrayList<MbtoolAction> savedActions = savedInstanceState.getParcelableArrayList(EXTRA_PENDING_ACTIONS);
        mPendingActions.addAll(savedActions);
    }/*ww w  . ja  v a2 s .com*/

    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);

    final FloatingActionMenu fabMenu = (FloatingActionMenu) getActivity().findViewById(R.id.fab_add_item_menu);
    FloatingActionButton fabAddPatchedFile = (FloatingActionButton) getActivity()
            .findViewById(R.id.fab_add_patched_file);
    FloatingActionButton fabAddBackup = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_backup);

    fabAddPatchedFile.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            addPatchedFile();
            fabMenu.close(true);
        }
    });
    fabAddBackup.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            addBackup();
            fabMenu.close(true);
        }
    });

    if (savedInstanceState != null) {
        mSelectedUri = savedInstanceState.getParcelable(EXTRA_SELECTED_URI);
        mSelectedUriFileName = savedInstanceState.getString(EXTRA_SELECTED_URI_FILE_NAME);
        mSelectedBackupDirUri = savedInstanceState.getParcelable(EXTRA_SELECTED_BACKUP_DIR_URI);
        mSelectedBackupName = savedInstanceState.getString(EXTRA_SELECTED_BACKUP_NAME);
        mSelectedBackupTargets = savedInstanceState.getStringArray(EXTRA_SELECTED_BACKUP_TARGETS);
        mSelectedRomId = savedInstanceState.getString(EXTRA_SELECTED_ROM_ID);
        mZipRomId = savedInstanceState.getString(EXTRA_ZIP_ROM_ID);
        mAddType = (Type) savedInstanceState.getSerializable(EXTRA_ADD_TYPE);
        mTaskIdVerifyZip = savedInstanceState.getInt(EXTRA_TASK_ID_VERIFY_ZIP);
        mQueryingMetadata = savedInstanceState.getBoolean(EXTRA_QUERYING_METADATA);
    }

    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.in_app_flashing_title,
                    R.string.in_app_flashing_dialog_first_use);
            d.show(getFragmentManager(), CONFIRM_DIALOG_FIRST_USE);
        }
    }

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

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

/**
 * EventBus listener for Event Bundle/*from   ww w  .j av a 2  s . co  m*/
 * @param {Bundle} event
 */
@Subscribe
public void onEventMainThread(Bundle event) {
    if (event.containsKey("request")) {
        return;
    }
    String name = event.getString("name");

    if (BackgroundGeolocationService.ACTION_START.equalsIgnoreCase(name)) {
        onStarted(event);
    } else if (BackgroundGeolocationService.ACTION_ON_MOTION_CHANGE.equalsIgnoreCase(name)) {
        boolean nowMoving = event.getBoolean("isMoving");
        try {
            JSONObject locationData = new JSONObject(event.getString("location"));
            onMotionChange(nowMoving, locationData);
        } catch (JSONException e) {
            Log.e(TAG, "Error decoding JSON");
            e.printStackTrace();
        }
    } else if (BackgroundGeolocationService.ACTION_GET_LOCATIONS.equalsIgnoreCase(name)) {
        try {
            JSONObject params = new JSONObject();
            params.put("locations", new JSONArray(event.getString("data")));
            params.put("taskId", "android-bg-task-id");
            PluginResult result = new PluginResult(PluginResult.Status.OK, params);
            getLocationsCallback.sendPluginResult(result);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            PluginResult result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
            getLocationsCallback.sendPluginResult(result);
        }
    } else if (BackgroundGeolocationService.ACTION_SYNC.equalsIgnoreCase(name)) {
        Boolean success = event.getBoolean("success");
        if (success) {
            try {
                JSONObject params = new JSONObject();
                params.put("locations", new JSONArray(event.getString("data")));
                params.put("taskId", "android-bg-task-id");
                PluginResult result = new PluginResult(PluginResult.Status.OK, params);
                syncCallback.sendPluginResult(result);
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else {
            PluginResult result = new PluginResult(PluginResult.Status.IO_EXCEPTION,
                    event.getString("message"));
            syncCallback.sendPluginResult(result);
        }
    } else if (BackgroundGeolocationService.ACTION_RESET_ODOMETER.equalsIgnoreCase(name)) {
        this.onResetOdometer(event);
    } else if (BackgroundGeolocationService.ACTION_CHANGE_PACE.equalsIgnoreCase(name)) {
        this.onChangePace(event);
    } else if (BackgroundGeolocationService.ACTION_GET_GEOFENCES.equalsIgnoreCase(name)) {
        try {
            JSONArray json = new JSONArray(event.getString("data"));
            PluginResult result = new PluginResult(PluginResult.Status.OK, json);
            getGeofencesCallback.sendPluginResult(result);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            PluginResult result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
            getGeofencesCallback.sendPluginResult(result);
        }
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_GOOGLE_PLAY_SERVICES_CONNECT_ERROR)) {
        GoogleApiAvailability.getInstance()
                .getErrorDialog(this.cordova.getActivity(), event.getInt("errorCode"), 1001).show();
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_LOCATION_ERROR)) {
        this.onLocationError(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_ADD_GEOFENCE)) {
        this.onAddGeofence(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_ADD_GEOFENCES)) {
        this.onAddGeofence(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_HTTP_RESPONSE)) {
        this.onHttpResponse(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_GET_CURRENT_POSITION)) {
        this.onLocationError(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_INSERT_LOCATION)) {
        this.onInsertLocation(event);
    } else if (name.equalsIgnoreCase(BackgroundGeolocationService.ACTION_GET_COUNT)) {
        this.onGetCount(event);
    }
}

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

@SuppressWarnings("unchecked")
@Override//  w  ww  . j  a va2  s  . c om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    conn = NetworkConnection.getInstance();
    view = inflater.inflate(R.layout.bufferslist, null);
    topUnreadIndicator = (LinearLayout) view.findViewById(R.id.topUnreadIndicator);
    topUnreadIndicator.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            int scrollTo = adapter.unreadPositionAbove(getListView().getFirstVisiblePosition());
            if (scrollTo > 0)
                getListView().setSelection(scrollTo - 1);
            else
                getListView().setSelection(0);

            updateUnreadIndicators(getListView().getFirstVisiblePosition(),
                    getListView().getLastVisiblePosition());
        }

    });
    topUnreadIndicatorColor = (LinearLayout) view.findViewById(R.id.topUnreadIndicatorColor);
    topUnreadIndicatorBorder = (LinearLayout) view.findViewById(R.id.topUnreadIndicatorBorder);
    bottomUnreadIndicator = (LinearLayout) view.findViewById(R.id.bottomUnreadIndicator);
    bottomUnreadIndicator.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            int offset = getListView().getLastVisiblePosition() - getListView().getFirstVisiblePosition();
            int scrollTo = adapter.unreadPositionBelow(getListView().getLastVisiblePosition()) - offset + 2;
            if (scrollTo < adapter.getCount())
                getListView().setSelection(scrollTo);
            else
                getListView().setSelection(adapter.getCount() - 1);

            updateUnreadIndicators(getListView().getFirstVisiblePosition(),
                    getListView().getLastVisiblePosition());
        }

    });
    bottomUnreadIndicatorColor = (LinearLayout) view.findViewById(R.id.bottomUnreadIndicatorColor);
    bottomUnreadIndicatorBorder = (LinearLayout) view.findViewById(R.id.bottomUnreadIndicatorBorder);
    listView = (ListView) view.findViewById(android.R.id.list);
    listView.setOnScrollListener(new OnScrollListener() {
        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            updateUnreadIndicators(firstVisibleItem, firstVisibleItem + visibleItemCount - 1);
        }

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }
    });
    listView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) {
            return mListener
                    .onBufferLongClicked(BuffersDataSource.getInstance().getBuffer(adapter.data.get(pos).bid));
        }

    });

    ready = NetworkConnection.getInstance().ready;

    if (ready) {
        if (savedInstanceState != null && savedInstanceState.containsKey("expandedArchives")) {
            ArrayList<Integer> expandedArchives = savedInstanceState.getIntegerArrayList("expandedArchives");
            Iterator<Integer> i = expandedArchives.iterator();
            while (i.hasNext()) {
                Integer cid = i.next();
                mExpandArchives.put(cid, true);
            }
        }
        refreshTask = new RefreshTask();
        refreshTask.doInBackground((Void) null);
        refreshTask.onPostExecute(null);
        if (savedInstanceState != null && savedInstanceState.containsKey("scrollPosition"))
            listView.setSelection(savedInstanceState.getInt("scrollPosition"));
    }
    return view;
}

From source file:com.skytree.epubtest.BookViewActivity.java

public void makeLayout() {
    // make fonts
    this.makeFonts();
    // clear the existing themes. 
    themes.clear();//from  w w  w .  j a v a2  s  .com
    // add themes 
    // String name,int foregroundColor,int backgroundColor,int controlColor,int controlHighlightColor,int seekBarColor,int seekThumbColor,int selectorColor,int selectionColor,String portraitName,String landscapeName,String doublePagedName,int bookmarkId
    themes.add(new Theme("white", Color.BLACK, 0xffffffff, Color.argb(240, 94, 61, 35), Color.LTGRAY,
            Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95), Color.DKGRAY, 0x22222222,
            "Phone-Portrait-White.png", "Phone-Landscape-White.png", "Phone-Landscape-Double-White.png",
            R.drawable.bookmark2x));
    themes.add(new Theme("brown", Color.BLACK, 0xffece3c7, Color.argb(240, 94, 61, 35),
            Color.argb(255, 255, 255, 255), Color.argb(240, 94, 61, 35), Color.argb(120, 160, 124, 95),
            Color.DKGRAY, 0x22222222, "Phone-Portrait-Brown.png", "Phone-Landscape-Brown.png",
            "Phone-Landscape-Double-Brown.png", R.drawable.bookmark2x));
    themes.add(new Theme("black", Color.LTGRAY, 0xff323230, Color.LTGRAY, Color.LTGRAY, Color.LTGRAY,
            Color.LTGRAY, Color.LTGRAY, 0x77777777, null, null, "Phone-Landscape-Double-Black.png",
            R.drawable.bookmarkgray2x));
    themes.add(new Theme("Leaf", 0xFF1F7F0E, 0xffF8F7EA, 0xFF186D08, Color.LTGRAY, 0xFF186D08, 0xFF186D08,
            Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x));
    themes.add(new Theme("", 0xFFA13A0A, 0xFFF6DFD9, 0xFFA13A0A, 0xFFDC4F0E, 0xFFA13A0A, 0xFFA13A0A,
            Color.DKGRAY, 0x22222222, null, null, null, R.drawable.bookmarkgray2x));
    this.setBrightness((float) setting.brightness);
    // create highlights object to contains highlights of this book. 
    highlights = new Highlights();
    Bundle bundle = getIntent().getExtras();
    fileName = bundle.getString("BOOKNAME");
    author = bundle.getString("AUTHOR");
    title = bundle.getString("TITLE");
    bookCode = bundle.getInt("BOOKCODE");
    if (pagePositionInBook == -1)
        pagePositionInBook = bundle.getDouble("POSITION");
    themeIndex = setting.theme;
    this.isGlobalPagination = bundle.getBoolean("GLOBALPAGINATION");
    this.isRTL = bundle.getBoolean("RTL");
    this.isVerticalWriting = bundle.getBoolean("VERTICALWRITING");
    this.isDoublePagedForLandscape = bundle.getBoolean("DOUBLEPAGED");
    //      if (this.isRTL) this.isDoublePagedForLandscape = false; // In RTL mode, SDK does not support double paged. 

    ePubView = new RelativeLayout(this);

    RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.FILL_PARENT);
    ePubView.setLayoutParams(rlp);

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height
    if (this.getOSVersion() >= 11) {
        rv = new ReflowableControl(this); // in case that device supports transparent webkit, the background image under the content can be shown. in some devices, content may be overlapped.
    } else {
        rv = new ReflowableControl(this, getCurrentTheme().backgroundColor); // in case that device can not support transparent webkit, the background color will be set in one color.
    }

    // if false highlight will be drawed on the back of text - this is default. 
    // for the very old devices of which GPU does not support transparent webView background, set the value to true.  
    rv.setDrawingHighlightOnFront(false);

    // set the bookCode to identify the book file. 
    rv.bookCode = this.bookCode;

    // set bitmaps for engine. 
    rv.setPagesStackImage(this.getBitmap("PagesStack.png"));
    rv.setPagesCenterImage(this.getBitmap("PagesCenter.png"));
    // for epub3 which has page-progression-direction="rtl", rv.isRTL() will return true.
    // for old RTL epub which does not have <spine toc="ncx" page-progression-direction="rtl"> in opf file. 
    // you can enforce RTL mode.  

    /*      
          // delay times for proper operations. 
          // !! DO NOT SET these values if there's no issue on your epub reader. !!
          // !! if delayTime is decresed, performance will be increase
          // !! if delayTime is set to too low value, a lot of problem can be occurred. 
          // bringDelayTime(default 500 ms) is for curlView and mainView transition - if the value is too short, blink may happen.
          rv.setBringDelayTime(500);
          // reloadDelayTime(default 100) is used for delay before reload (eg. changeFont, loadChapter or etc) 
          rv.setReloadDelayTime(100);
          // reloadDelayTimeForRotation(default 1000) is used for delay before rotation
          rv.setReloadDelayTimeForRotation(1000);
          // retotaionDelayTime(default 1500) is used for delay after rotation.
          rv.setRotationDelayTime(1500);
          // finalDelayTime(default 500) is used for the delay after loading chapter. 
          rv.setFinalDelayTime(500);
          // rotationFactor affects the delayTime before Rotation. default value 1.0f
          rv.setRotationFactor(1.0f);      
          // If recalcDelayTime is too short, setContentBackground function failed to work properly.  
          rv.setRecalcDelayTime(2500);
    */

    // set the max width or height for background. 
    rv.setMaxSizeForBackground(1024);
    //      rv.setBaseDirectory(SkySetting.getStorageDirectory() + "/books");
    //      rv.setBookName(fileName);
    // set the file path of epub to open
    // Be sure that the file exists before setting.
    rv.setBookPath(SkySetting.getStorageDirectory() + "/books/" + fileName);
    // if true, double pages will be displayed on landscape mode. 
    rv.setDoublePagedForLandscape(this.isDoublePagedForLandscape);
    // set the initial font style for book. 
    rv.setFont(setting.fontName, this.getRealFontSize(setting.fontSize));
    // set the initial line space for book. 
    rv.setLineSpacing(this.getRealLineSpace(setting.lineSpacing)); // the value is supposed to be percent(%).
    // set the horizontal gap(margin) on both left and right side of each page.  
    rv.setHorizontalGapRatio(0.30);
    // set the vertical gap(margin) on both top and bottom side of each page. 
    rv.setVerticalGapRatio(0.22);
    // set the HighlightListener to handle text highlighting. 
    rv.setHighlightListener(new HighlightDelegate());
    // set the PageMovedListener which is called whenever page is moved. 
    rv.setPageMovedListener(new PageMovedDelegate());
    // set the SelectionListener to handle text selection. 
    rv.setSelectionListener(new SelectionDelegate());
    // set the pagingListener which is called when GlobalPagination is true. this enables the calculation for the total number of pages in book, not in chapter.   
    rv.setPagingListener(new PagingDelegate());
    // set the searchListener to search keyword.
    rv.setSearchListener(new SearchDelegate());
    // set the stateListener to monitor the state of sdk engine. 
    rv.setStateListener(new StateDelegate());
    // set the clickListener which is called when user clicks
    rv.setClickListener(new ClickDelegate());
    // set the bookmarkListener to toggle bookmark
    rv.setBookmarkListener(new BookmarkDelegate());
    // set the scriptListener to set custom javascript. 
    rv.setScriptListener(new ScriptDelegate());

    // enable/disable scroll mode
    rv.setScrollMode(false);

    // for some anroid device, when rendering issues are occurred, use "useSoftwareLayer"
    //      rv.useSoftwareLayer();
    // In search keyword, if true, sdk will return search result with the full information such as position, pageIndex. 
    rv.setFullSearch(true);
    // if true, sdk will return raw text for search result, highlight text or body text without character escaping.  
    rv.setRawTextRequired(false);

    // if true, sdk will read the content of book directry from file system, not via Internal server. 
    //      rv.setDirectRead(true);

    // If you want to make your own provider, please look into EpubProvider.java in Advanced demo.
    //      EpubProvider epubProvider = new EpubProvider();
    //      rv.setContentProvider(epubProvider);      

    // SkyProvider is the default ContentProvider which is presented with SDK. 
    // SkyProvider can read the content of epub file without unzipping. 
    // SkyProvider is also fully integrated with SkyDRM solution.  
    SkyProvider skyProvider = new SkyProvider();
    skyProvider.setKeyListener(new KeyDelegate());
    rv.setContentProvider(skyProvider);

    // set the start positon to open the book. 
    rv.setStartPositionInBook(pagePositionInBook);
    // DO NOT USE BELOW, if true , sdk will use DOM to highlight text.  
    //      rv.useDOMForHighlight(false);
    // if true, globalPagination will be activated. 
    // this enables the calculation of page number based on entire book ,not on each chapter.
    // this globalPagination consumes huge computing power. 
    // AVOID GLOBAL PAGINATION FOR LOW SPEC DEVICES.
    rv.setGlobalPagination(this.isGlobalPagination);
    // set the navigation area on both left and right side to go to the previous or next page when the area is clicked. 
    rv.setNavigationAreaWidthRatio(0.1f); // both left and right side.
    // set the device locked to prevent Rotation. 
    rv.setRotationLocked(setting.lockRotation);
    isRotationLocked = setting.lockRotation;
    // set the mediaOverlayListener for MediaOverlay.
    rv.setMediaOverlayListener(new MediaOverlayDelegate());
    // set the audio playing based on Sequence. 
    rv.setSequenceBasedForMediaOverlay(false);

    params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    params.width = LayoutParams.MATCH_PARENT;
    params.height = LayoutParams.MATCH_PARENT;

    rv.setLayoutParams(params);
    this.applyThemeToRV(themeIndex);

    if (this.isFullScreenForNexus && SkyUtility.isNexus() && Build.VERSION.SDK_INT >= 19) {
        rv.setImmersiveMode(true);
    }
    // If you want to get the license key for commercial use, please email us (skytree21@gmail.com). 
    // Without the license key, watermark message will be shown in background. 
    rv.setLicenseKey("a99b-3914-a63b-8ecb");

    // set PageTransition Effect 
    int transitionType = bundle.getInt("transitionType");
    if (transitionType == 0) {
        rv.setPageTransition(PageTransition.None);
    } else if (transitionType == 1) {
        rv.setPageTransition(PageTransition.Slide);
    } else if (transitionType == 2) {
        rv.setPageTransition(PageTransition.Curl);
    }

    // setCurlQuality effects the image quality when tuning page in Curl Transition Mode. 
    // If "Out of Memory" occurs in high resolution devices with big screen, 
    // this value should be decreased like 0.25f or below.
    if (this.getMaxSize() > 1280) {
        rv.setCurlQuality(0.5f);
    }

    // set the color of text selector. 
    rv.setSelectorColor(getCurrentTheme().selectorColor);
    // set the color of text selection area. 
    rv.setSelectionColor(getCurrentTheme().selectionColor);

    // setCustomDrawHighlight & setCustomDrawCaret work only if SDK >= 11
    // if true, sdk will ask you how to draw the highlighted text
    rv.setCustomDrawHighlight(true);
    // if true, sdk will require you to draw the custom selector.
    rv.setCustomDrawCaret(true);

    rv.setFontUnit("px");

    rv.setFingerTractionForSlide(true);
    rv.setVideoListener(new VideoDelegate());

    // make engine not to send any event to iframe
    // if iframe clicked, onIFrameClicked will be fired with source of iframe
    // By Using that source of iframe, you can load the content of iframe in your own webView or another browser. 
    rv.setSendingEventsToIFrameEnabled(false);

    // make engine send any event to video(tag) or not
    // if video tag is clicked, onVideoClicked will be fired with source of iframe
    // By Using that source of video, you can load the content of video in your own media controller or another browser. 
    rv.setSendingEventsToVideoEnabled(true);

    // make engine send any event to video(tag) or not
    // if video tag is clicked, onVideoClicked will be fired with source of iframe
    // By Using that source of video, you can load the content of video in your own media controller or another browser.
    rv.setSendingEventsToAudioEnabled(true);

    // if true, sdk will return the character offset from the chapter beginning , not from element index.
    // then startIndex, endIndex of highlight will be 0 (zero) 
    rv.setGlobalOffset(true);
    // if true, sdk will return the text of each page in the PageInformation object which is passed in onPageMoved event. 
    rv.setExtractText(true);

    ePubView.addView(rv);

    this.makeControls();
    this.makeBoxes();
    this.makeIndicator();
    this.recalcFrames();
    if (this.isRTL) {
        this.seekBar.setReversed(true);
    }
    setContentView(ePubView);
    this.isInitialized = true;
}

From source file:com.irccloud.android.activity.PastebinEditorActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name),
                cloud, 0xFFF2F7FC));//ww  w  . j a v a2s. c  o m
        cloud.recycle();
    }
    setContentView(R.layout.activity_pastebineditor);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if (getSupportActionBar() != null) {
        if (!getWindow().isFloating()) {
            getSupportActionBar().setDisplayShowHomeEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    paste = (EditText) findViewById(R.id.paste);
    filename = (EditText) findViewById(R.id.filename);
    message = (EditText) findViewById(R.id.message);
    messages_count = (TextView) findViewById(R.id.messages_count);

    if (savedInstanceState != null && savedInstanceState.containsKey("message"))
        message.setText(savedInstanceState.getString("message"));

    if (savedInstanceState != null && savedInstanceState.containsKey("paste_id"))
        pasteID = savedInstanceState.getString("paste_id");
    else if (getIntent() != null && getIntent().hasExtra("paste_id"))
        pasteID = getIntent().getStringExtra("paste_id");

    if (savedInstanceState != null && savedInstanceState.containsKey("paste_contents"))
        pastecontents = savedInstanceState.getString("paste_contents");
    else if (getIntent() != null && getIntent().hasExtra("paste_contents"))
        pastecontents = getIntent().getStringExtra("paste_contents");
    paste.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            int count = 0;
            String lines[] = editable.toString().split("\n");
            for (String line : lines) {
                count += Math.ceil(line.length() / 1080.0f);
            }
            messages_count.setText("Text will be sent as " + count + " message" + (count == 1 ? "" : "s"));
        }
    });
    paste.setText(pastecontents);

    if (savedInstanceState != null && savedInstanceState.containsKey("filename"))
        filename.setText(savedInstanceState.getString("filename"));
    else if (getIntent() != null && getIntent().hasExtra("filename"))
        filename.setText(getIntent().getStringExtra("filename"));

    tabHost = (TabLayout) findViewById(android.R.id.tabhost);
    ViewCompat.setElevation(toolbar, ViewCompat.getElevation(tabHost));

    if (pasteID != null) {
        tabHost.setVisibility(View.GONE);
        message.setVisibility(View.GONE);
        findViewById(R.id.message_heading).setVisibility(View.GONE);
    } else {
        tabHost.setTabGravity(TabLayout.GRAVITY_FILL);
        tabHost.setTabMode(TabLayout.MODE_FIXED);
        tabHost.addTab(tabHost.newTab().setText("Pastebin"));
        tabHost.addTab(tabHost.newTab().setText("Messages"));
        tabHost.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                current_tab = tab.getPosition();
                if (current_tab == 0) {
                    filename.setVisibility(View.VISIBLE);
                    message.setVisibility(View.VISIBLE);
                    messages_count.setVisibility(View.GONE);
                    findViewById(R.id.filename_heading).setVisibility(View.VISIBLE);
                    findViewById(R.id.message_heading).setVisibility(View.VISIBLE);
                } else {
                    filename.setVisibility(View.GONE);
                    message.setVisibility(View.GONE);
                    messages_count.setVisibility(View.VISIBLE);
                    findViewById(R.id.filename_heading).setVisibility(View.GONE);
                    findViewById(R.id.message_heading).setVisibility(View.GONE);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
        if (savedInstanceState != null && savedInstanceState.containsKey("tab"))
            tabHost.getTabAt(savedInstanceState.getInt("tab")).select();
    }

    NetworkConnection.getInstance().addHandler(this);
    if (pasteID != null && (pastecontents == null || pastecontents.length() == 0)) {
        new FetchPastebinTask().execute((Void) null);
    }

    if (pasteID != null) {
        setTitle(R.string.title_activity_pastebin_editor_edit);
        toolbar.setBackgroundResource(R.drawable.actionbar);
    } else {
        setTitle(R.string.title_activity_pastebin_editor);
    }

    supportInvalidateOptionsMenu();

    result(RESULT_CANCELED);
}

From source file:fr.univsavoie.ltp.client.MainActivity.java

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

    // Appliquer le thme LTP a l'ActionBar
    //setTheme(R.style.Theme_ltp);

    // Cration de l'activit principale
    setContentView(R.layout.activity_main);

    // Instancier les classes utiles
    setPopup(new Popup(this));
    setSession(new Session(this));
    setTools(new Tools(this));

    // Afficher la ActionBar
    ActionBar mActionBar = getSupportActionBar();
    mActionBar.setHomeButtonEnabled(true);
    mActionBar.setDisplayShowHomeEnabled(true);

    // MapView settings
    map = (MapView) findViewById(R.id.openmapview);
    map.setTileSource(TileSourceFactory.MAPNIK);
    map.setBuiltInZoomControls(false);/*from   w  w w  . j  ava  2 s. c  o m*/
    map.setMultiTouchControls(true);

    // MapController settings
    mapController = map.getController();

    //To use MapEventsReceiver methods, we add a MapEventsOverlay:
    overlay = new MapEventsOverlay(this, this);
    map.getOverlays().add(overlay);

    boolean isWifiEnabled = false;
    boolean isGPSEnabled = false;

    // Vrifier si le wifi ou le rseau mobile est activ
    final ConnectivityManager connMgr = (ConnectivityManager) this
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    final NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    final NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    if (wifi.isAvailable() && (wifi.getDetailedState() == DetailedState.CONNECTING
            || wifi.getDetailedState() == DetailedState.CONNECTED)) {
        Toast.makeText(this, R.string.toast_wifi, Toast.LENGTH_LONG).show();
        isWifiEnabled = true;
    } else if (mobile.isAvailable() && (mobile.getDetailedState() == DetailedState.CONNECTING
            || mobile.getDetailedState() == DetailedState.CONNECTED)) {
        Toast.makeText(this, R.string.toast_3G, Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(this, R.string.toast_aucun_reseau, Toast.LENGTH_LONG).show();
    }

    // Obtenir le service de localisation
    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    // Verifier si le service de localisation GPS est actif, le cas echeant, tester le rseau
    if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 250.0f, this);
        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        isGPSEnabled = true;
    } else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 30 * 1000, 250.0f, this);
        location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    }

    // Afficher une boite de dialogue et proposer d'activer un ou plusieurs services pas actifs
    if (!isWifiEnabled || !isGPSEnabled) {
        //getTools().showSettingsAlert(this, isWifiEnabled, isGPSEnabled);
    }

    // Si on a une localisation, on dfinit ses coordonnes geopoint
    if (location != null) {
        startPoint = new GeoPoint(location.getLatitude(), location.getLongitude());
    } else {
        // Sinon, on indique des paramtres par dfaut
        location = getTools().getLastKnownLocation(locationManager);
        if (location == null) {
            location = new Location("");
            location.setLatitude(46.227638);
            location.setLongitude(2.213749000000);
        }
        startPoint = new GeoPoint(46.227638, 2.213749000000);
    }

    setLongitude(location.getLongitude());
    setLatitude(location.getLatitude());

    destinationPoint = null;
    viaPoints = new ArrayList<GeoPoint>();

    // On recupre quelques paramtres de la session prcdents si possible
    if (savedInstanceState == null) {
        mapController.setZoom(15);
        mapController.setCenter(startPoint);
    } else {
        mapController.setZoom(savedInstanceState.getInt("zoom_level"));
        mapController.setCenter((GeoPoint) savedInstanceState.getParcelable("map_center"));
    }

    // Crer un overlay sur la carte pour afficher notre point de dpart
    myLocationOverlay = new SimpleLocationOverlay(this, new DefaultResourceProxyImpl(this));
    map.getOverlays().add(myLocationOverlay);
    myLocationOverlay.setLocation(startPoint);

    // Boutton pour zoomer la carte
    ImageButton btZoomIn = (ImageButton) findViewById(R.id.btZoomIn);
    btZoomIn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            map.getController().zoomIn();
        }
    });

    // Boutton pour dezoomer la carte
    ImageButton btZoomOut = (ImageButton) findViewById(R.id.btZoomOut);
    btZoomOut.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            map.getController().zoomOut();
        }
    });

    // Pointeurs d'itinrairea:
    final ArrayList<ExtendedOverlayItem> waypointsItems = new ArrayList<ExtendedOverlayItem>();
    itineraryMarkers = new ItemizedOverlayWithBubble<ExtendedOverlayItem>(this, waypointsItems, map,
            new ViaPointInfoWindow(R.layout.itinerary_bubble, map));
    map.getOverlays().add(itineraryMarkers);
    //updateUIWithItineraryMarkers();

    Button searchButton = (Button) findViewById(R.id.buttonSearch);
    searchButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            handleSearchLocationButton();
        }
    });

    //context menu for clicking on the map is registered on this button. 
    registerForContextMenu(searchButton);

    // Routes et Itinraires
    final ArrayList<ExtendedOverlayItem> roadItems = new ArrayList<ExtendedOverlayItem>();
    roadNodeMarkers = new ItemizedOverlayWithBubble<ExtendedOverlayItem>(this, roadItems, map);
    map.getOverlays().add(roadNodeMarkers);

    if (savedInstanceState != null) {
        mRoad = savedInstanceState.getParcelable("road");
        updateUIWithRoad(mRoad);
    }

    //POIs:
    //POI search interface:
    String[] poiTags = getResources().getStringArray(R.array.poi_tags);
    poiTagText = (AutoCompleteTextView) findViewById(R.id.poiTag);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,
            poiTags);
    poiTagText.setAdapter(adapter);
    Button setPOITagButton = (Button) findViewById(R.id.buttonSetPOITag);
    setPOITagButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //Hide the soft keyboard:
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(poiTagText.getWindowToken(), 0);
            //Start search:
            getPOIAsync(poiTagText.getText().toString());
        }
    });

    //POI markers:
    final ArrayList<ExtendedOverlayItem> poiItems = new ArrayList<ExtendedOverlayItem>();
    poiMarkers = new ItemizedOverlayWithBubble<ExtendedOverlayItem>(this, poiItems, map,
            new POIInfoWindow(map));
    map.getOverlays().add(poiMarkers);
    if (savedInstanceState != null) {
        mPOIs = savedInstanceState.getParcelableArrayList("poi");
        updateUIWithPOI(mPOIs);
    }

    // Load friends ListView
    lvListeFriends = (ListView) findViewById(R.id.listViewFriends);
    //lvListeFriends.setBackgroundResource(R.drawable.listview_roundcorner_item);
    lvListeFriends.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> adapter, View v, int position, long id) {
            Friends item = (Friends) adapter.getItemAtPosition(position);
            if (item.getLongitude() != 0.0 && item.getLatitude() != 0.0) {
                destinationPoint = new GeoPoint(item.getLongitude(), item.getLatitude());
                markerDestination = putMarkerItem(markerDestination, destinationPoint, DEST_INDEX,
                        R.string.destination, R.drawable.marker_destination, -1);
                getRoadAsync();
                map.getController().setCenter(destinationPoint);
            } else {
                Toast.makeText(MainActivity.this, R.string.toast_friend_statut, Toast.LENGTH_LONG).show();
            }
        }
    });

    viewMapFilters = (ScrollView) this.findViewById(R.id.scrollViewMapFilters);
    viewMapFilters.setVisibility(View.GONE);

    // Initialiser tout ce qui est donnes utilisateur propres  l'activit
    init();

    getTools().relocateUser(mapController, map, myLocationOverlay, location);
}