List of usage examples for android.os Bundle getFloat
@Override public float getFloat(String key)
From source file:io.jawg.osmcontributor.ui.fragments.MapFragment.java
private void instantiateMapBox(Bundle savedInstanceState) { // LocationView settings mapboxMap.getMyLocationViewSettings().setAccuracyAlpha(0); mapboxMap.getMyLocationViewSettings() .setForegroundTintColor(ContextCompat.getColor(getActivity(), R.color.colorPrimaryTransparent)); // Set the map center and zoom to the saved values or use the default values getUserLocation();//from w w w . j a va 2 s . co m CameraPosition.Builder cameraBuilder = new CameraPosition.Builder(); if (savedInstanceState == null) { double lat = sharedPreferences.getFloat("latitude", 0); double lon = sharedPreferences.getFloat("longitude", 0); if (lat != 0 && lon != 0) { cameraBuilder.target(new LatLng(lat, lon)).zoom(11); } } else { cameraBuilder.target((LatLng) savedInstanceState.getParcelable(LOCATION)) .zoom(savedInstanceState.getFloat(ZOOM_LEVEL)); } mapboxMap.setCameraPosition(cameraBuilder.build()); eventBus.post(new PleaseInitializeArpiEvent()); presenter.setForceRefreshPoi(); presenter.setForceRefreshNotes(); presenter.loadPoisIfNeeded(); eventBus.post(new PleaseInitializeNoteDrawerEvent(displayOpenNotes, displayClosedNotes)); if (poiTypePickerAdapter != null) { poiTypePickerAdapter.setExpertMode( sharedPreferences.getBoolean(getString(R.string.shared_prefs_expert_mode), false)); } mapboxListener.listen(mapboxMap, mapView); mapboxMap.getMarkerViewManager() .addMarkerViewAdapter(new LocationMarkerViewAdapter(getActivity().getApplicationContext())); }
From source file:org.de.jmg.learn.MainActivity.java
private void processBundle(Bundle savedInstanceState) throws Exception { final String tmppath = Path.combine(getApplicationInfo().dataDir, "vok.tmp"); boolean CardMode; if (savedInstanceState != null) { libLearn.gStatus = "onCreate Load SavedInstanceState"; ActionBarOriginalTextSize = savedInstanceState.getFloat("ActionBarOriginalTextSize"); String filename = savedInstanceState.getString("vokpath"); Uri uri = null;/*from w w w . j a va2 s. c o m*/ String strURI = savedInstanceState.getString("URI"); try { mPager.setCurrentItem(savedInstanceState.getInt("SelFragID", 0)); } catch (Exception e) { e.printStackTrace(); } if (!libString.IsNullOrEmpty(strURI)) uri = Uri.parse(strURI); int index = savedInstanceState.getInt("vokindex"); int[] Lernvokabeln = savedInstanceState.getIntArray("Lernvokabeln"); int Lernindex = savedInstanceState.getInt("Lernindex"); CardMode = savedInstanceState.getBoolean("Cardmode", false); if (index > 0) { _blnUniCode = savedInstanceState.getBoolean("Unicode", true); LoadVokabel(tmppath, uri, index, Lernvokabeln, Lernindex, CardMode); vok.setLastIndex(savedInstanceState.getInt("vokLastIndex", vok.getLastIndex())); vok.setFileName(filename); vok.setURI(uri); vok.setCardMode(CardMode); vok.aend = savedInstanceState.getBoolean("aend", true); vok.AnzRichtig = savedInstanceState.getInt("Right", 0); vok.AnzFalsch = savedInstanceState.getInt("Wrong", 0); /* if (fPA.fragMain!=null && fPA.fragMain.mainView!=null) { fPA.fragMain.getVokabel(false, false); } */ } /* if (fPA.fragSettings!=null) { fPA.fragSettings.onCreateView(LayoutInflater.from(this), Layout, null); } */ //mPager.setCurrentItem(savedInstanceState.getInt("SelFragID", 0)); } else { libLearn.gStatus = "getting lastfile"; String strURI = prefs.getString("URI", ""); String filename = prefs.getString("LastFile", ""); String UriName = prefs.getString("FileName", ""); int[] Lernvokabeln = lib.getIntArrayFromPrefs(prefs, "Lernvokabeln"); if (!libString.IsNullOrEmpty(strURI) || !libString.IsNullOrEmpty(filename) || (vok.checkLernvokabeln(Lernvokabeln))) { libLearn.gStatus = "onCreate Load Lastfile"; Uri uri = null; if (!libString.IsNullOrEmpty(strURI)) { uri = Uri.parse(strURI); lib.CheckPermissions(this, uri, false); } int index = prefs.getInt("vokindex", 1); int Lernindex = prefs.getInt("Lernindex", 0); _blnUniCode = prefs.getBoolean("Unicode", true); boolean isTmpFile = prefs.getBoolean("isTmpFile", false); boolean aend = prefs.getBoolean("aend", true); CardMode = prefs.getBoolean("Cardmode", false); if (Lernvokabeln != null) { if (isTmpFile) { libLearn.gStatus = "getting lastfile load tmpfile"; LoadVokabel(tmppath, uri, index, Lernvokabeln, Lernindex, CardMode); vok.setFileName(filename); vok.setURI(uri); vok.setURIName(UriName); vok.setCardMode(CardMode); vok.setLastIndex(prefs.getInt("vokLastIndex", vok.getLastIndex())); vok.aend = aend; } else { libLearn.gStatus = "getting lastfile load file"; LoadVokabel(filename, uri, index, Lernvokabeln, Lernindex, CardMode); vok.setLastIndex(prefs.getInt("vokLastIndex", vok.getLastIndex())); } } else { if (isTmpFile) { libLearn.gStatus = "getting lastfiletmp no Lernvokablen"; LoadVokabel(tmppath, uri, 1, null, 0, CardMode); vok.setFileName(filename); vok.setURI(uri); vok.setCardMode(CardMode); vok.aend = aend; } else { libLearn.gStatus = "getting lastfile no Lernvokablen"; LoadVokabel(filename, uri, 1, null, 0, CardMode); } } } } }
From source file:de.sourcestream.movieDB.controller.TVDetailsInfo.java
/** * Fired when are restoring from backState or orientation has changed. * * @param args our bundle with saved state. Our parent fragment handles the saving. *///from w w w . j av a 2s . c om @SuppressWarnings("ConstantConditions") private void onOrientationChange(Bundle args) { // BackDrop path backDropCheck = args.getInt("backDropCheck"); if (backDropCheck == 0) { activity.setBackDropImage(backDropPath, args.getString("backDropUrl")); backDropPath.setTag(args.getString("backDropUrl")); } // Release date and title activity.setTextFromHtml(title, args.getString("titleText")); // Status activity.setText(statusText, args.getString("status")); // Type if (!args.getString("typeText").isEmpty()) activity.setText(typeText, args.getString("typeText")); else activity.hideView(typeText); // Episode runtime if (!args.getString("episodeRuntime").isEmpty()) activity.setText(episodeRuntime, args.getString("episodeRuntime")); else activity.hideView(episodeRuntime); // Number of episodes if (!args.getString("numberOfEpisodesText").isEmpty()) activity.setText(numberOfEpisodesText, args.getString("numberOfEpisodesText")); else activity.hideView(numberOfEpisodesText); // Number of seasons if (!args.getString("numberOfSeasonsText").isEmpty()) activity.setText(numberOfSeasonsText, args.getString("numberOfSeasonsText")); else activity.hideView(numberOfSeasonsText); // First air date if (!args.getString("firstAirDateText").isEmpty()) activity.setText(firstAirDateText, args.getString("firstAirDateText")); else activity.hideView(firstAirDateText); // Last air date if (!args.getString("lastAirDateText").isEmpty()) activity.setText(lastAirDateText, args.getString("lastAirDateText")); else activity.hideView(lastAirDateText); // Genres if (!args.getString("genres").isEmpty()) activity.setText(genres, args.getString("genres")); else activity.hideView(genres); // Production Countries if (!args.getString("productionCountries").isEmpty()) activity.setText(countries, args.getString("productionCountries")); else activity.hideView(countries); // Production Companies if (!args.getString("productionCompanies").isEmpty()) { activity.setText(companies, args.getString("productionCompanies")); if (args.getString("productionCountries").isEmpty()) { ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) companies.getLayoutParams(); lp.setMargins(0, (int) (28 * getResources().getDisplayMetrics().density), 0, 0); } } else activity.hideView(companies); // Poster path if (args.getString("posterPathURL") != null) { activity.setImage(posterPath, args.getString("posterPathURL")); activity.setImageTag(posterPath, args.getString("posterPathURL")); } // Rating if (args.getString("voteCount").isEmpty()) { activity.hideRatingBar(ratingBar); activity.hideTextView(voteCount); } else { ratingBar.setRating(args.getFloat("rating")); activity.setText(voteCount, args.getString("voteCount")); } // Similar list similarList = args.getParcelableArrayList("similarList"); if (similarList != null && similarList.size() > 0) setSimilarList(similarList); else activity.hideView(similarHolder); }
From source file:io.karim.materialtabs.sample.TabsActivity.java
private void applyParametersFromIntentExtras() { Intent intent = getIntent();/*from w w w.j a va 2s. c om*/ if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { Resources resources = getResources(); int showToolbar = extras.getBoolean(TabsSettingsFragment.SHOW_TOOLBAR) ? View.VISIBLE : View.GONE; int indicatorColor = resources.getColor(extras.getInt(TabsSettingsFragment.INDICATOR_COLOR)); int underlineColor = resources.getColor(extras.getInt(TabsSettingsFragment.UNDERLINE_COLOR)); int indicatorHeightDp = extras.getInt(TabsSettingsFragment.INDICATOR_HEIGHT); int underlineHeightDp = extras.getInt(TabsSettingsFragment.UNDERLINE_HEIGHT); int tabPaddingDp = extras.getInt(TabsSettingsFragment.TAB_PADDING); mToolbar.setVisibility(showToolbar); mMaterialTabs.setIndicatorColor(indicatorColor); mMaterialTabs.setUnderlineColor(underlineColor); mMaterialTabs.setIndicatorHeight(Utils.dpToPx(resources, indicatorHeightDp)); mMaterialTabs.setUnderlineHeight(Utils.dpToPx(resources, underlineHeightDp)); mMaterialTabs.setTabPaddingLeftRight(Utils.dpToPx(resources, tabPaddingDp)); boolean paddingMiddle = extras.getBoolean(TabsSettingsFragment.PADDING_MIDDLE); boolean sameWeightTabs = extras.getBoolean(TabsSettingsFragment.SAME_WEIGHT_TABS); boolean textAllCaps = extras.getBoolean(TabsSettingsFragment.TEXT_ALL_CAPS); mMaterialTabs.setPaddingMiddle(paddingMiddle); mMaterialTabs.setSameWeightTabs(sameWeightTabs); mMaterialTabs.setAllCaps(textAllCaps); int toolbarColor = resources.getColor(extras.getInt(TabsSettingsFragment.TOOLBAR_BACKGROUND)); int tabBackgroundColor = resources.getColor(extras.getInt(TabsSettingsFragment.TAB_BACKGROUND)); mToolbar.setBackgroundColor(toolbarColor); mMaterialTabs.setBackgroundColor(tabBackgroundColor); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(Color.argb(Color.alpha(toolbarColor), Color.red(toolbarColor) / 2, Color.green(toolbarColor) / 2, Color.blue(toolbarColor) / 2)); } int textColorSelected = resources.getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_SELECTED)); int textColorUnselected = resources .getColor(extras.getInt(TabsSettingsFragment.TEXT_COLOR_UNSELECTED)); int tabStyleSelected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_SELECTED); int tabStyleUnselected = extras.getInt(TabsSettingsFragment.TEXT_STYLE_UNSELECTED); mMaterialTabs.setTextColorSelected(textColorSelected); mMaterialTabs.setTextColorUnselected(textColorUnselected); mMaterialTabs.setTabTypefaceSelectedStyle(tabStyleSelected); mMaterialTabs.setTabTypefaceUnselectedStyle(tabStyleUnselected); int rippleDuration = extras.getInt(RippleSettingsFragment.RIPPLE_DURATION); float rippleAlphaFloat = extras.getFloat(RippleSettingsFragment.RIPPLE_ALPHA_FLOAT); int rippleColor = resources.getColor(extras.getInt(RippleSettingsFragment.RIPPLE_COLOR)); boolean rippleDelayClick = extras.getBoolean(RippleSettingsFragment.RIPPLE_DELAY_CLICK); float rippleDiameterDp = extras.getFloat(RippleSettingsFragment.RIPPLE_DIAMETER); int rippleFadeDuration = extras.getInt(RippleSettingsFragment.RIPPLE_FADE_DURATION); int rippleHighlightColor = resources .getColor(extras.getInt(RippleSettingsFragment.RIPPLE_HIGHLIGHT_COLOR)); boolean rippleOverlay = extras.getBoolean(RippleSettingsFragment.RIPPLE_OVERLAY); boolean ripplePersistent = extras.getBoolean(RippleSettingsFragment.RIPPLE_PERSISTENT); int rippleRoundedCornusRadiusDp = extras .getInt(RippleSettingsFragment.RIPPLE_ROUNDED_CORNERS_RADIUS); mMaterialTabs.setRippleDuration(rippleDuration); mMaterialTabs.setRippleAlphaFloat(rippleAlphaFloat); mMaterialTabs.setRippleColor(rippleColor); mMaterialTabs.setRippleDelayClick(rippleDelayClick); mMaterialTabs.setRippleDiameterDp(rippleDiameterDp); mMaterialTabs.setRippleFadeDuration(rippleFadeDuration); mMaterialTabs.setRippleHighlightColor(rippleHighlightColor); mMaterialTabs.setRippleInAdapter(false); mMaterialTabs.setRippleOverlay(rippleOverlay); mMaterialTabs.setRipplePersistent(ripplePersistent); mMaterialTabs.setRippleRoundedCornersDp(rippleRoundedCornusRadiusDp); mExportableString = createExportableText(showToolbar, indicatorColor, underlineColor, indicatorHeightDp, underlineHeightDp, tabPaddingDp, paddingMiddle, sameWeightTabs, textAllCaps, toolbarColor, tabBackgroundColor, textColorSelected, textColorUnselected, tabStyleSelected, tabStyleUnselected, rippleDuration, rippleAlphaFloat, rippleColor, rippleDelayClick, rippleDiameterDp, rippleFadeDuration, rippleHighlightColor, rippleOverlay, ripplePersistent, rippleRoundedCornusRadiusDp); } } }
From source file:androidx.media.MediaSession2StubImplBase.java
@Override public void onCommand(String command, final Bundle extras, final ResultReceiver cb) { switch (command) { case CONTROLLER_COMMAND_CONNECT: connect(extras, cb);/* w ww. j a va 2 s . c o m*/ break; case CONTROLLER_COMMAND_DISCONNECT: disconnect(extras); break; case CONTROLLER_COMMAND_BY_COMMAND_CODE: { final int commandCode = extras.getInt(ARGUMENT_COMMAND_CODE); IMediaControllerCallback caller = (IMediaControllerCallback) extras .getBinder(ARGUMENT_ICONTROLLER_CALLBACK); if (caller == null) { return; } onCommand2(caller.asBinder(), commandCode, new Session2Runnable() { @Override public void run(ControllerInfo controller) { switch (commandCode) { case COMMAND_CODE_PLAYBACK_PLAY: mSession.play(); break; case COMMAND_CODE_PLAYBACK_PAUSE: mSession.pause(); break; case COMMAND_CODE_PLAYBACK_RESET: mSession.reset(); break; case COMMAND_CODE_PLAYBACK_PREPARE: mSession.prepare(); break; case COMMAND_CODE_PLAYBACK_SEEK_TO: { long seekPos = extras.getLong(ARGUMENT_SEEK_POSITION); mSession.seekTo(seekPos); break; } case COMMAND_CODE_PLAYLIST_SET_REPEAT_MODE: { int repeatMode = extras.getInt(ARGUMENT_REPEAT_MODE); mSession.setRepeatMode(repeatMode); break; } case COMMAND_CODE_PLAYLIST_SET_SHUFFLE_MODE: { int shuffleMode = extras.getInt(ARGUMENT_SHUFFLE_MODE); mSession.setShuffleMode(shuffleMode); break; } case COMMAND_CODE_PLAYLIST_SET_LIST: { List<MediaItem2> list = MediaUtils2 .fromMediaItem2ParcelableArray(extras.getParcelableArray(ARGUMENT_PLAYLIST)); MediaMetadata2 metadata = MediaMetadata2 .fromBundle(extras.getBundle(ARGUMENT_PLAYLIST_METADATA)); mSession.setPlaylist(list, metadata); break; } case COMMAND_CODE_PLAYLIST_SET_LIST_METADATA: { MediaMetadata2 metadata = MediaMetadata2 .fromBundle(extras.getBundle(ARGUMENT_PLAYLIST_METADATA)); mSession.updatePlaylistMetadata(metadata); break; } case COMMAND_CODE_PLAYLIST_ADD_ITEM: { int index = extras.getInt(ARGUMENT_PLAYLIST_INDEX); MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.addPlaylistItem(index, item); break; } case COMMAND_CODE_PLAYLIST_REMOVE_ITEM: { MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.removePlaylistItem(item); break; } case COMMAND_CODE_PLAYLIST_REPLACE_ITEM: { int index = extras.getInt(ARGUMENT_PLAYLIST_INDEX); MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.replacePlaylistItem(index, item); break; } case COMMAND_CODE_PLAYLIST_SKIP_TO_NEXT_ITEM: { mSession.skipToNextItem(); break; } case COMMAND_CODE_PLAYLIST_SKIP_TO_PREV_ITEM: { mSession.skipToPreviousItem(); break; } case COMMAND_CODE_PLAYLIST_SKIP_TO_PLAYLIST_ITEM: { MediaItem2 item = MediaItem2.fromBundle(extras.getBundle(ARGUMENT_MEDIA_ITEM)); mSession.skipToPlaylistItem(item); break; } case COMMAND_CODE_VOLUME_SET_VOLUME: { int value = extras.getInt(ARGUMENT_VOLUME); int flags = extras.getInt(ARGUMENT_VOLUME_FLAGS); VolumeProviderCompat vp = mSession.getVolumeProvider(); if (vp == null) { // TODO: Revisit } else { vp.onSetVolumeTo(value); } break; } case COMMAND_CODE_VOLUME_ADJUST_VOLUME: { int direction = extras.getInt(ARGUMENT_VOLUME_DIRECTION); int flags = extras.getInt(ARGUMENT_VOLUME_FLAGS); VolumeProviderCompat vp = mSession.getVolumeProvider(); if (vp == null) { // TODO: Revisit } else { vp.onAdjustVolume(direction); } break; } case COMMAND_CODE_SESSION_REWIND: { mSession.getCallback().onRewind(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_FAST_FORWARD: { mSession.getCallback().onFastForward(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID: { String mediaId = extras.getString(ARGUMENT_MEDIA_ID); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPlayFromMediaId(mSession.getInstance(), controller, mediaId, extra); break; } case COMMAND_CODE_SESSION_PLAY_FROM_SEARCH: { String query = extras.getString(ARGUMENT_QUERY); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPlayFromSearch(mSession.getInstance(), controller, query, extra); break; } case COMMAND_CODE_SESSION_PLAY_FROM_URI: { Uri uri = extras.getParcelable(ARGUMENT_URI); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPlayFromUri(mSession.getInstance(), controller, uri, extra); break; } case COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID: { String mediaId = extras.getString(ARGUMENT_MEDIA_ID); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPrepareFromMediaId(mSession.getInstance(), controller, mediaId, extra); break; } case COMMAND_CODE_SESSION_PREPARE_FROM_SEARCH: { String query = extras.getString(ARGUMENT_QUERY); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPrepareFromSearch(mSession.getInstance(), controller, query, extra); break; } case COMMAND_CODE_SESSION_PREPARE_FROM_URI: { Uri uri = extras.getParcelable(ARGUMENT_URI); Bundle extra = extras.getBundle(ARGUMENT_EXTRAS); mSession.getCallback().onPrepareFromUri(mSession.getInstance(), controller, uri, extra); break; } case COMMAND_CODE_SESSION_SET_RATING: { String mediaId = extras.getString(ARGUMENT_MEDIA_ID); Rating2 rating = Rating2.fromBundle(extras.getBundle(ARGUMENT_RATING)); mSession.getCallback().onSetRating(mSession.getInstance(), controller, mediaId, rating); break; } case COMMAND_CODE_SESSION_SUBSCRIBE_ROUTES_INFO: { mSession.getCallback().onSubscribeRoutesInfo(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_UNSUBSCRIBE_ROUTES_INFO: { mSession.getCallback().onUnsubscribeRoutesInfo(mSession.getInstance(), controller); break; } case COMMAND_CODE_SESSION_SELECT_ROUTE: { Bundle route = extras.getBundle(ARGUMENT_ROUTE_BUNDLE); mSession.getCallback().onSelectRoute(mSession.getInstance(), controller, route); break; } case COMMAND_CODE_PLAYBACK_SET_SPEED: { float speed = extras.getFloat(ARGUMENT_PLAYBACK_SPEED); mSession.setPlaybackSpeed(speed); break; } } } }); break; } case CONTROLLER_COMMAND_BY_CUSTOM_COMMAND: { final SessionCommand2 customCommand = SessionCommand2 .fromBundle(extras.getBundle(ARGUMENT_CUSTOM_COMMAND)); IMediaControllerCallback caller = (IMediaControllerCallback) extras .getBinder(ARGUMENT_ICONTROLLER_CALLBACK); if (caller == null || customCommand == null) { return; } final Bundle args = extras.getBundle(ARGUMENT_ARGUMENTS); onCommand2(caller.asBinder(), customCommand, new Session2Runnable() { @Override public void run(ControllerInfo controller) throws RemoteException { mSession.getCallback().onCustomCommand(mSession.getInstance(), controller, customCommand, args, cb); } }); break; } } }
From source file:pl.edu.agh.mindmapex.gui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); progressDialog = ProgressDialog.show(this, "Drawing", "Please wait...", true, false); if (WelcomeScreen.workbook != null) { workbook = WelcomeScreen.workbook; }//ww w.jav a 2s. c o m res = getResources(); if (handler == null) { handler = WorkbookHandler.createNewWorkbook(); } if (workbook == null) { workbook = handler.getWorkbook(); styleSheet = workbook.getStyleSheet(); style1 = styleSheet.createStyle(IStyle.TOPIC); styleSheet.addStyle(style1, IStyleSheet.NORMAL_STYLES); } styleSheet = workbook.getStyleSheet(); sheet1 = workbook.getPrimarySheet(); res = getResources(); if (style == null) { Intent intent = getIntent(); style = intent.getStringExtra(WelcomeScreen.STYLE); } if (root == null) { // Display display = getWindowManager().getDefaultDisplay(); setContentView(R.layout.main_content_view); lay = (DrawView) findViewById(R.id.main_draw_view); lay.post(new Runnable() { @Override public void run() { rootTopic = sheet1.getRootTopic(); root = new Box(); // Point size = new Point(lay.getWidth(), lay.getHeight()); // width = size.x / 2; // height = size.y / 2; root.setPoint(new pl.edu.agh.mindmapex.common.Point( lay.getWidth() / 2 - getResources().getDimensionPixelSize(R.dimen.init_box_size), lay.getHeight() / 2 - getResources().getDimensionPixelSize(R.dimen.init_box_size_height))); lay.setZOrderOnTop(true); if (style.equals("ReadyMap")) { if (sheet1.getTheme() == null) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; boxes.put(root.topic.getId(), root); b.point = new pl.edu.agh.mindmapex.common.Point(); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } b.parent = root; root.addChild(b); rootTopic.add(b.topic, 0, ITopic.ATTACHED); Utils.fireAddSubtopic(b, boxes); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else { if (sheet1.getTheme().getName().equals("%classic") || sheet1.getTheme().getName().equals("%comic")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); root.topic = rootTopic; final HashMap<String, Box> boxes = new HashMap<>(); if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.elipse)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } b.parent = root; root.addChild(b); Utils.fireAddSubtopic(b, boxes); rootTopic.add(b.topic, 0, ITopic.ATTACHED); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else if (sheet1.getTheme().getName().equals("%simple")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.elipse)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.no_border)); } b.parent = root; root.addChild(b); rootTopic.add(b.topic, 0, ITopic.ATTACHED); Utils.fireAddSubtopic(b, boxes); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else if (sheet1.getTheme().getName().equals("%bussiness")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); } root.topic.setFolded(false); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.rect)); } b.parent = root; root.addChild(b); rootTopic.add(b.topic, 0, ITopic.ATTACHED); Utils.fireAddSubtopic(b, boxes); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } else if (sheet1.getTheme().getName().equals("%academese")) { root.setPoint(new pl.edu.agh.mindmapex.common.Point(width, height)); final HashMap<String, Box> boxes = new HashMap<>(); root.topic = rootTopic; if (root.topic.getStyleId() != null) { checkStyle(root); } else { root.setDrawableShape(res.getDrawable(R.drawable.rect)); } root.topic.setFolded(false); Style s = (Style) workbook.getStyleSheet().createStyle(IStyle.MAP); s.setProperty(Styles.FillColor, Integer.toString(res.getColor(R.color.dark_gray), 16)); styleSheet.addStyle(s, IStyleSheet.NORMAL_STYLES); sheet1.setStyleId(s.getId()); lay.setBackgroundColor(res.getColor(R.color.dark_gray)); boxes.put(root.topic.getId(), root); for (ITopic t : root.topic.getAllChildren()) { Box b = new Box(); b.topic = t; b.point = new pl.edu.agh.mindmapex.common.Point(); boxes.put(root.topic.getId(), root); if (b.topic.getStyleId() != null) { checkStyle(b); } else { b.setDrawableShape(res.getDrawable(R.drawable.elipse)); } b.parent = root; root.addChild(b); Utils.fireAddSubtopic(b, boxes); rootTopic.add(b.topic, 0, ITopic.ATTACHED); boxes.put(t.getId(), b); } Utils.findRelationships(boxes); } } } else if (style.equals("Default")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#CCE5FF"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ROUNDEDRECT); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_STRAIGHT); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Classic")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.elipse)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setName("%classic"); style2.setProperty(Styles.FillColor, String.valueOf(res.getColor(R.color.light_yellow))); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setThemeId(style2.getId()); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#9ACD32"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ELLIPSE); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_CURVE); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Simple")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.elipse)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setName("%simple"); style2.setProperty(Styles.FillColor, String.valueOf(res.getColor(R.color.white))); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setThemeId(style2.getId()); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#FFFFFF"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ELLIPSE); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_CURVE); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Business")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.round_rect)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setName("%business"); style2.setProperty(Styles.FillColor, String.valueOf(res.getColor(R.color.white))); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setThemeId(style2.getId()); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#B87333"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_ROUNDEDRECT); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_CURVE); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } else if (style.equals("Academese")) { rootTopic.setTitleText("Central Topic"); root.topic = rootTopic; root.topic.setFolded(false); root.setDrawableShape(res.getDrawable(R.drawable.rect)); IStyle style2 = styleSheet.createStyle(IStyle.THEME); style2.setProperty(Styles.FillColor, "#404040"); styleSheet.addStyle(style2, IStyleSheet.NORMAL_STYLES); sheet1.setStyleId(style2.getId()); lay.setBackgroundColor(res.getColor(R.color.dark_gray)); IStyle style3 = styleSheet.createStyle(IStyle.TOPIC); style3.setProperty(Styles.FillColor, "#404040"); style3.setProperty(Styles.ShapeClass, Styles.TOPIC_SHAPE_RECT); style3.setProperty(Styles.LineClass, Styles.BRANCH_CONN_STRAIGHT); style3.setProperty(Styles.LineColor, "#FFFFFF"); styleSheet.addStyle(style3, IStyleSheet.NORMAL_STYLES); style2.setProperty(Style.TOPIC, style3.getId()); rootTopic.setStyleId(style3.getId()); } } }); } else { setContentView(R.layout.main_content_view); lay = (DrawView) findViewById(R.id.main_draw_view); lay.setZOrderOnTop(true); } gestureDetector = new GestureDetector(this, gestList); Utils.lay = lay; if (lay != null) { lay.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); switch (event.getActionMasked()) { case (MotionEvent.ACTION_OUTSIDE): return true; case (MotionEvent.ACTION_UP): break; case MotionEvent.ACTION_POINTER_UP: if (!detector.isInProgress()) { int count = event.getPointerCount(); // Number of 'fingers' in this time Utils.getCoordsInView(lay, event, 1); boxEdited = Utils.whichBox(lay, event); float[] tab1 = Utils.getCoordsInView(lay, event, 0); float[] tab = Utils.getCoordsInView(lay, event, 1); if (count == 2 && boxEdited != null) { if (tab.length == 2) { if (mTourGuide != null) mTourGuide.cleanUp(); Box box1 = new Box(); box1.setPoint(new pl.edu.agh.mindmapex.common.Point( (int) tab[0] - (box1.getWidth() / 2), (int) tab[1] - (box1.getHeight() / 2))); AddBox addBox = new AddBox(); Properties properties = new Properties(); properties.put("box", MainActivity.boxEdited); properties.put("new_box", box1); properties.put("root", root); properties.put("res", res); properties.put("style", style); addBox.execute(properties); MainActivity.addCommendUndo(addBox); editContent(box1, addBox); lay.updateBoxWithText(box1); } } break; } default: break; } boolean response = gestureDetector.onTouchEvent(event); lay.requestFocus(); InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); in.hideSoftInputFromWindow(lay.getApplicationWindowToken(), 0); return response; } }); lay.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } Utils.context = this; this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.show(); detector = new ScaleGestureDetector(this, new SimpleOnScaleGestureListener() { @Override public boolean onScaleBegin(ScaleGestureDetector detector) { mScaling = true; return true; } @Override public boolean onScale(ScaleGestureDetector detector) { // float focusX = detector.getFocusX(); // float focusY = detector.getFocusY(); //// lay.setPivotX(mid.x); //// lay.setPivotY(mid.y); //// lay.pivotx = (int) (lastFocusX + detector.getFocusX())/2; //// lay.pivoty = (int) (lastFocusY+ detector.getFocusY())/2; // // lay.pivotx = (int) mid.x; // // lay.pivoty = (int) mid.y; // // lay.canvas.translate(-focusX,-focusY); lay.pivotx = detector.getFocusX(); lay.pivoty = detector.getFocusY(); // lay.transx = (lay.pivotx); // lay.transy = (lay.pivoty); // lay.pivotx = (int) mid.x; // lay.pivoty = (int) mid.y; // lay.setPivotX(lastFocusX); // lay.setPivotY(lastFocusY); float SF = detector.getScaleFactor(); lay.zoomx *= SF; lay.zoomy *= SF; // lay.canvas.scale(SF, SF, mid.x, mid.y); // float focusShiftX = focusX - lastFocusX; // float focusShiftY = focusY - lastFocusY; //lay.canvas.translate(focusX + focusShiftX, focusY + focusShiftY); // lastFocusX = focusX; // lastFocusY = focusY; // lay.transy = detector.getFocusY(); // lay.zoomx = Math.max(0.1f, Math.min(lay.zoomx, 5.0f)); // lay.zoomy = Math.max(0.1f, Math.min(lay.zoomy, 5.0f)); return true; } }); progressDialog.dismiss(); lay.setId(View.generateViewId()); lay.setSaveEnabled(true); if (savedInstanceState != null) { lay.transx = savedInstanceState.getFloat(TRANSX_KEY); lay.transy = savedInstanceState.getFloat(TRANSY_KEY); lay.zoomx = savedInstanceState.getFloat(ZOOMX_KEY); lay.zoomy = savedInstanceState.getFloat(ZOOMY_KEY); lay.pivotx = savedInstanceState.getFloat(PIVOTX_KEY); lay.pivoty = savedInstanceState.getFloat(PIVOTY_KEY); } }