Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Slider compare #526

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MapboxAndroidDemo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ dependencies {
compile 'com.google.code.gson:gson:2.8'

// Mapbox dependencies
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.2.0-beta.2@aar') {
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.4@aar') {
transitive = true
}

Expand All @@ -104,6 +104,7 @@ dependencies {
compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.afollestad.material-dialogs:commons:0.9.4.5'
compile 'com.github.Cutta:GifView:1.1'

gpservicesCompile 'com.google.firebase:firebase-crash:11.0.4'
compile project(':SharedCode')
}
Expand Down
7 changes: 7 additions & 0 deletions MapboxAndroidDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity"/>
</activity>
<activity
android:name=".labs.SliderCompareActivity"
android:label="@string/activity_labs_slider_compare_title">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.mapbox.mapboxandroiddemo.MainActivity"/>
</activity>
<activity
android:name=".examples.dds.StyleCirclesCategoricallyActivity"
android:label="@string/activity_dds_style_circle_categorically_title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
import com.mapbox.mapboxandroiddemo.labs.PictureInPictureActivity;
import com.mapbox.mapboxandroiddemo.labs.RecyclerViewOnMapActivity;
import com.mapbox.mapboxandroiddemo.labs.RecyclerViewSymbolLayerActivity;
import com.mapbox.mapboxandroiddemo.labs.SliderCompareActivity;
import com.mapbox.mapboxandroiddemo.labs.SpaceStationLocationActivity;
import com.mapbox.mapboxandroiddemo.model.ExampleItemModel;
import com.mapbox.mapboxandroiddemo.utils.ItemClickSupport;
Expand Down Expand Up @@ -618,6 +619,12 @@ private void listItems(int id) {
new Intent(MainActivity.this, RecyclerViewSymbolLayerActivity.class),
R.string.activity_lab_rv_symbol_layer_on_map_url, true
));
exampleItemModel.add(new ExampleItemModel(
R.string.activity_labs_slider_compare_title,
R.string.activity_labs_slider_compare_description,
new Intent(MainActivity.this, SliderCompareActivity.class),
R.string.activity_labs_slider_compare_url, true
));
currentCategory = R.id.nav_lab;
break;
case R.id.nav_dds:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.mapbox.mapboxandroiddemo.labs;

import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.SeekBar;

import com.mapbox.mapboxandroiddemo.R;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;

public class SliderCompareActivity extends AppCompatActivity {

private MapView mapViewOne;
private MapView mapViewTwo;
private SeekBar seekBar;
private String TAG = "SliderCompareActivity";

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

// Mapbox access token is configured here. This needs to be called either in your application
// object or in the same activity which contains the mapview.
Mapbox.getInstance(this, getString(R.string.access_token));

// This contains the MapView in XML and needs to be called after the access token is configured.
setContentView(R.layout.activity_slider_compare);

mapViewOne = (MapView) findViewById(R.id.mapViewOne);
mapViewTwo = (MapView) findViewById(R.id.mapViewTwo);
seekBar = (SeekBar) findViewById(R.id.slider_compare_seek_bar);

mapViewOne.onCreate(savedInstanceState);
mapViewTwo.onCreate(savedInstanceState);
mapViewOne.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {

findViewById(R.id.slider_compare_container).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d(TAG, "onTouch: ");
mapViewOne.onTouchEvent(event);
mapViewTwo.onTouchEvent(event);
return false;
}
});
}
});

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progressValue, boolean fromUser) {
Log.d(TAG, "onProgressChanged: progressValue = " + progressValue);
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.target_framelayout);
frameLayout.setLayoutParams(new CoordinatorLayout.LayoutParams(progressValue, frameLayout.getLayoutParams().height));
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
});
}

// Add the mapViewOne lifecycle to the activity's lifecycle methods
@Override
public void onResume() {
super.onResume();
mapViewOne.onResume();
mapViewTwo.onResume();
}

@Override
protected void onStart() {
super.onStart();
mapViewOne.onStart();
mapViewTwo.onStart();
}

@Override
protected void onStop() {
super.onStop();
mapViewOne.onStop();
mapViewTwo.onStop();
}

@Override
public void onPause() {
super.onPause();
mapViewOne.onPause();
mapViewTwo.onPause();
}

@Override
public void onLowMemory() {
super.onLowMemory();
mapViewOne.onLowMemory();
mapViewTwo.onLowMemory();
}

@Override
protected void onDestroy() {
super.onDestroy();
mapViewOne.onDestroy();
mapViewTwo.onDestroy();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapViewOne.onSaveInstanceState(outState);
mapViewTwo.onSaveInstanceState(outState);
}
}
59 changes: 59 additions & 0 deletions MapboxAndroidDemo/src/main/res/layout/activity_slider_compare.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
android:id="@+id/slider_compare_container"
android:layout_width="match_parent"
android:layout_height="match_parent">


<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapViewOne"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="40.73581"
mapbox:mapbox_cameraTargetLng="-73.99155"
mapbox:mapbox_cameraZoom="11"
mapbox:mapbox_renderTextureMode="true"
mapbox:mapbox_styleUrl="@string/mapbox_style_mapbox_streets"
mapbox:mapbox_uiAttribution="false"
mapbox:mapbox_uiDoubleTapGestures="false"
mapbox:mapbox_uiLogo="false"
mapbox:mapbox_uiRotateGestures="false"
mapbox:mapbox_uiScrollGestures="false"
mapbox:mapbox_uiTiltGestures="false"
mapbox:mapbox_uiZoomGestures="false"/>

<FrameLayout
android:id="@+id/target_framelayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapViewTwo"
android:layout_width="300dp"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="40.73581"
mapbox:mapbox_cameraTargetLng="-73.99155"
mapbox:mapbox_cameraZoom="11"
mapbox:mapbox_renderTextureMode="true"
mapbox:mapbox_styleUrl="@string/mapbox_style_dark"
mapbox:mapbox_uiAttribution="false"
mapbox:mapbox_uiDoubleTapGestures="false"
mapbox:mapbox_uiLogo="false"
mapbox:mapbox_uiRotateGestures="false"
mapbox:mapbox_uiScrollGestures="false"
mapbox:mapbox_uiTiltGestures="false"
mapbox:mapbox_uiZoomGestures="false"/>

</FrameLayout>

<SeekBar
android:id="@+id/slider_compare_seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:max="600"
android:progress="300"/>


</android.support.design.widget.CoordinatorLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,6 @@
<string name="activity_lab_rv_symbol_layer_on_map_description">Add markers via SymbolLayer and manipulate the map based on recyclerview interactions.</string>
<string name="activity_lab_mapillary_description">Add Mapillary vector tiles to a map</string>
<string name="activity_labs_inset_map_description">Show a smaller inset map fragment and link it to a larger map for two map interaction. Great for gaming!</string>
<string name="activity_labs_slider_compare_description">Compare two different maps by sliding a comparison bar across them</string>

</resources>
1 change: 1 addition & 0 deletions MapboxAndroidDemo/src/main/res/values/titles_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,6 @@
<string name="activity_lab_indoor_map_title">Indoor Map</string>
<string name="activity_labs_mapillary_title">Mapillary integration</string>
<string name="activity_labs_inset_map_title">Inset map</string>
<string name="activity_labs_slider_compare_title">Slider compare</string>

</resources>
1 change: 1 addition & 0 deletions MapboxAndroidDemo/src/main/res/values/urls_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
<string name="activity_lab_rv_symbol_layer_on_map_url" translatable="false">https://i.imgur.com/YQlJL3x.jpg</string>
<string name="activity_lab_mapillary_url" translatable="false">http://i.imgur.com/w4SSif1.png</string>
<string name="activity_labs_inset_map_url" translatable="false">https://i.imgur.com/jp4wc24.png</string>
<string name="activity_labs_slider_compare_url" translatable="false">https://i.imgur.com/3LxODOu.png</string>

</resources>
1 change: 1 addition & 0 deletions MapboxAndroidWearDemo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
tools:node="replace"
android:theme="@android:style/Theme.DeviceDefault">

<meta-data
Expand Down
28 changes: 14 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
}
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.firebase:firebase-plugins:1.1.1'
}
}

allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://maven.google.com" }
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://maven.google.com" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
delete rootProject.buildDir
}