Search in sources :

Example 81 with Pair

use of net.imglib2.util.Pair in project Shuttle by timusus.

the class BaseDetailFragment method pushDetailController.

void pushDetailController(BaseDetailFragment detailFragment, String tag, View transitionView) {
    List<Pair<View, String>> transitions = new ArrayList<>();
    String transitionName = ViewCompat.getTransitionName(transitionView);
    transitions.add(new Pair<>(transitionView, transitionName));
    transitions.add(new Pair<>(toolbar, "toolbar"));
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
        Transition moveTransition = TransitionInflater.from(getContext()).inflateTransition(R.transition.image_transition);
        detailFragment.setSharedElementEnterTransition(moveTransition);
        detailFragment.setSharedElementReturnTransition(moveTransition);
    }
    getNavigationController().pushViewController(detailFragment, tag, transitions);
}
Also used : ArrayList(java.util.ArrayList) Transition(android.transition.Transition) Pair(android.support.v4.util.Pair)

Example 82 with Pair

use of net.imglib2.util.Pair in project Osmand by osmandapp.

the class MapillaryImageDialog method fetchTiles.

public void fetchTiles() {
    RotatedTileBox tileBox = getMapActivity().getMapView().getCurrentRotatedTileBox().copy();
    if (fetchedTileLat == tileBox.getLatitude() && fetchedTileLon == tileBox.getLongitude()) {
        return;
    }
    ITileSource map = TileSourceManager.getMapillaryVectorSource();
    int nzoom = tileBox.getZoom();
    if (nzoom < map.getMinimumZoomSupported()) {
        return;
    }
    ResourceManager mgr = getMapActivity().getMyApplication().getResourceManager();
    final QuadRect tilesRect = tileBox.getTileBounds();
    // recalculate for ellipsoid coordinates
    float ellipticTileCorrection = 0;
    if (map.isEllipticYTile()) {
        ellipticTileCorrection = (float) (MapUtils.getTileEllipsoidNumberY(nzoom, tileBox.getLatitude()) - tileBox.getCenterTileY());
    }
    int left = (int) Math.floor(tilesRect.left);
    int top = (int) Math.floor(tilesRect.top + ellipticTileCorrection);
    int width = (int) Math.ceil(tilesRect.right - left);
    int height = (int) Math.ceil(tilesRect.bottom + ellipticTileCorrection - top);
    int dzoom = nzoom - TILE_ZOOM;
    int div = (int) Math.pow(2.0, dzoom);
    Map<String, Pair<QuadPointDouble, GeometryTile>> tiles = new HashMap<>();
    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            int tileX = (left + i) / div;
            int tileY = (top + j) / div;
            String tileId = mgr.calculateTileId(map, tileX, tileY, TILE_ZOOM);
            Pair<QuadPointDouble, GeometryTile> p = tiles.get(tileId);
            if (p == null) {
                GeometryTile tile = null;
                // asking tile image async
                boolean imgExist = mgr.tileExistOnFileSystem(tileId, map, tileX, tileY, TILE_ZOOM);
                if (imgExist) {
                    if (sync) {
                        tile = mgr.getGeometryTilesCache().getTileForMapSync(tileId, map, tileX, tileY, TILE_ZOOM, false);
                        sync = false;
                    } else {
                        tile = mgr.getGeometryTilesCache().getTileForMapAsync(tileId, map, tileX, tileY, TILE_ZOOM, false);
                    }
                }
                if (tile != null) {
                    tiles.put(tileId, new Pair<>(new QuadPointDouble(tileX, tileY), tile));
                }
            }
        }
    }
    fetchedTileLat = tileBox.getLatitude();
    fetchedTileLon = tileBox.getLongitude();
    this.tiles = new ArrayList<>(tiles.values());
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) HashMap(java.util.HashMap) ResourceManager(net.osmand.plus.resources.ResourceManager) QuadRect(net.osmand.data.QuadRect) Point(com.vividsolutions.jts.geom.Point) SuppressLint(android.annotation.SuppressLint) ITileSource(net.osmand.map.ITileSource) GeometryTile(net.osmand.data.GeometryTile) Pair(android.support.v4.util.Pair) QuadPointDouble(net.osmand.data.QuadPointDouble)

Example 83 with Pair

use of net.imglib2.util.Pair in project Osmand by osmandapp.

the class MapOverlayAction method getOnAddBtnClickListener.

@Override
protected View.OnClickListener getOnAddBtnClickListener(final MapActivity activity, final Adapter adapter) {
    return new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final OsmandSettings settings = activity.getMyApplication().getSettings();
            Map<String, String> entriesMap = settings.getTileSourceEntries();
            entriesMap.put(KEY_NO_OVERLAY, activity.getString(R.string.no_overlay));
            AlertDialog.Builder builder = new AlertDialog.Builder(activity);
            final ArrayList<String> keys = new ArrayList<>(entriesMap.keySet());
            final String[] items = new String[entriesMap.size()];
            int i = 0;
            for (String it : entriesMap.values()) {
                items[i++] = it;
            }
            final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, R.layout.dialog_text_item);
            arrayAdapter.addAll(items);
            builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int i) {
                    Pair<String, String> layer = new Pair<>(keys.get(i), items[i]);
                    adapter.addItem(layer, activity);
                    dialog.dismiss();
                }
            }).setNegativeButton(R.string.shared_string_cancel, null);
            builder.show();
        }
    };
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings) ArrayAdapter(android.widget.ArrayAdapter) Pair(android.support.v4.util.Pair)

Example 84 with Pair

use of net.imglib2.util.Pair in project Osmand by osmandapp.

the class MapOverlayAction method execute.

@Override
public void execute(MapActivity activity) {
    OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
    if (plugin != null) {
        OsmandSettings settings = activity.getMyApplication().getSettings();
        List<Pair<String, String>> sources = loadListFromParams();
        Pair<String, String> currentSource = new Pair<>(settings.MAP_OVERLAY.get(), settings.MAP_OVERLAY.get());
        Pair<String, String> nextSource = sources.get(0);
        int index = sources.indexOf(currentSource);
        if (index >= 0 && index + 1 < sources.size()) {
            nextSource = sources.get(index + 1);
        }
        boolean hasOverlay = !nextSource.first.equals(KEY_NO_OVERLAY);
        if (hasOverlay) {
            settings.MAP_OVERLAY.set(nextSource.first);
            settings.MAP_OVERLAY_PREVIOUS.set(nextSource.first);
        } else {
            settings.MAP_OVERLAY.set(null);
            settings.MAP_OVERLAY_PREVIOUS.set(null);
        }
        plugin.updateMapLayers(activity.getMapView(), settings.MAP_OVERLAY, activity.getMapLayers());
        Toast.makeText(activity, activity.getString(R.string.quick_action_map_overlay_switch, nextSource.second), Toast.LENGTH_SHORT).show();
    }
}
Also used : OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin) OsmandSettings(net.osmand.plus.OsmandSettings) Pair(android.support.v4.util.Pair)

Example 85 with Pair

use of net.imglib2.util.Pair in project gh4a by slapperwan.

the class RepositoryActivity method loadOrShowRefSelection.

private void loadOrShowRefSelection() {
    if (mBranches != null) {
        showRefSelectionDialog();
    } else {
        final RepositoryBranchService branchService = ServiceFactory.get(RepositoryBranchService.class, false);
        final RepositoryService repoService = ServiceFactory.get(RepositoryService.class, false);
        Single<List<Branch>> branchSingle = ApiHelpers.PageIterator.toSingle(page -> branchService.getBranches(mRepoOwner, mRepoName, page));
        Single<List<Branch>> tagSingle = ApiHelpers.PageIterator.toSingle(page -> repoService.getTags(mRepoOwner, mRepoName, page));
        registerTemporarySubscription(Single.zip(branchSingle, tagSingle, Pair::create).compose(RxUtils::doInBackground).compose(RxUtils.wrapWithProgressDialog(this, R.string.loading_msg)).subscribe(result -> {
            mBranches = result.first;
            mTags = result.second;
            showRefSelectionDialog();
        }, this::handleLoadFailure));
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Context(android.content.Context) ContentListContainerFragment(com.gh4a.fragment.ContentListContainerFragment) Repository(com.meisolsson.githubsdk.model.Repository) Bundle(android.os.Bundle) StarringService(com.meisolsson.githubsdk.service.activity.StarringService) Uri(android.net.Uri) ImageView(android.widget.ImageView) RepositoryEventListFragment(com.gh4a.fragment.RepositoryEventListFragment) Intent(android.content.Intent) RepositoryFragment(com.gh4a.fragment.RepositoryFragment) Response(retrofit2.Response) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) UiUtils(com.gh4a.utils.UiUtils) ArrayList(java.util.ArrayList) Commit(com.meisolsson.githubsdk.model.Commit) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) R(com.gh4a.R) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) IntentUtils(com.gh4a.utils.IntentUtils) Subscription(com.meisolsson.githubsdk.model.Subscription) RepositoryBranchService(com.meisolsson.githubsdk.service.repositories.RepositoryBranchService) ApiHelpers(com.gh4a.utils.ApiHelpers) BaseFragmentPagerActivity(com.gh4a.BaseFragmentPagerActivity) LayoutInflater(android.view.LayoutInflater) Fragment(android.support.v4.app.Fragment) RepositoryService(com.meisolsson.githubsdk.service.repositories.RepositoryService) TextUtils(android.text.TextUtils) WatchingService(com.meisolsson.githubsdk.service.activity.WatchingService) ViewGroup(android.view.ViewGroup) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) TextView(android.widget.TextView) RxUtils(com.gh4a.utils.RxUtils) BaseAdapter(android.widget.BaseAdapter) Gh4Application(com.gh4a.Gh4Application) CommitListFragment(com.gh4a.fragment.CommitListFragment) Pair(android.support.v4.util.Pair) Branch(com.meisolsson.githubsdk.model.Branch) ServiceFactory(com.gh4a.ServiceFactory) BookmarksProvider(com.gh4a.db.BookmarksProvider) SubscriptionRequest(com.meisolsson.githubsdk.model.request.activity.SubscriptionRequest) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryBranchService(com.meisolsson.githubsdk.service.repositories.RepositoryBranchService) RepositoryService(com.meisolsson.githubsdk.service.repositories.RepositoryService) Pair(android.support.v4.util.Pair)

Aggregations

Pair (android.support.v4.util.Pair)79 ArrayList (java.util.ArrayList)49 Pair (org.apache.commons.math3.util.Pair)38 View (android.view.View)28 List (java.util.List)22 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)19 Intent (android.content.Intent)18 TextView (android.widget.TextView)15 HashMap (java.util.HashMap)15 Map (java.util.Map)15 Arrays (java.util.Arrays)13 Test (org.junit.Test)12 ImageView (android.widget.ImageView)11 RecyclerView (android.support.v7.widget.RecyclerView)9 Collections (java.util.Collections)9 Person (org.drools.modelcompiler.domain.Person)9 KieSession (org.kie.api.runtime.KieSession)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 Assertions (org.assertj.core.api.Assertions)7 Cursor (android.database.Cursor)4