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

Commit

Permalink
Added sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermo.mazzola committed Jun 10, 2017
1 parent fac6282 commit 338f83c
Show file tree
Hide file tree
Showing 13 changed files with 400 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,24 @@
import android.view.View;
import android.view.ViewGroup;

import com.google.android.gms.maps.GoogleMapOptions;
import com.google.android.gms.maps.MapFragment;

public class NestedScrollMapFragment extends MapFragment {

public static NestedScrollMapFragment newInstance() {
return new NestedScrollMapFragment();
}

public static NestedScrollMapFragment newInstance(GoogleMapOptions options) {
NestedScrollMapFragment fragment = new NestedScrollMapFragment();

Bundle args = new Bundle();
args.putParcelable("MapOptions", options);
fragment.setArguments(args);
return fragment;
}

@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View view = super.onCreateView(layoutInflater, viewGroup, bundle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,24 @@
import android.view.View;
import android.view.ViewGroup;

import com.google.android.gms.maps.GoogleMapOptions;
import com.google.android.gms.maps.SupportMapFragment;

public class SupportNestedScrollMapFragment extends SupportMapFragment {

public static SupportNestedScrollMapFragment newInstance() {
return new SupportNestedScrollMapFragment();
}

public static SupportNestedScrollMapFragment newInstance(GoogleMapOptions options) {
SupportNestedScrollMapFragment fragment = new SupportNestedScrollMapFragment();

Bundle args = new Bundle();
args.putParcelable("MapOptions", options);
fragment.setArguments(args);
return fragment;
}

@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
View view = super.onCreateView(layoutInflater, viewGroup, bundle);
Expand Down
24 changes: 24 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId 'gs.utils.maps.nestedscroll.demo'
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
}

def appCompatVersion = '25.3.1'

dependencies {
compile project(':nestedscroll-maps')

compile "com.android.support:design:$appCompatVersion"
compile "com.android.support:cardview-v7:$appCompatVersion"
compile 'com.google.android.gms:play-services-maps:11.0.0'
}
24 changes: 24 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="gs.utils.maps.nestedscroll.demo">

<application
android:label="@string/app_name"
android:theme="@style/AppTheme">

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyCUr_Wkwl0RqmzXnNZ8ibeIxvJB-MakFwk" />

<activity
android:name=".DemoActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package gs.utils.maps.nestedscroll.demo;

import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.Toast;

import com.google.android.gms.maps.GoogleMapOptions;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;

import gs.utils.maps.nestedscroll.SupportNestedScrollMapFragment;

public class DemoActivity extends AppCompatActivity implements RadioGroup.OnCheckedChangeListener {
private final GoogleMapOptions mapOptions = new GoogleMapOptions()
.camera(CameraPosition.fromLatLngZoom(new LatLng(-38.006004, -57.543122), 14));

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

setContentView(R.layout.activity_demo);

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

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View view) {
Toast.makeText(view.getContext(), "Click!", Toast.LENGTH_SHORT).show();
}

});

RadioGroup groupMapType = (RadioGroup) findViewById(R.id.groupMapType);
groupMapType.setOnCheckedChangeListener(this);
groupMapType.check(R.id.showNestedMap);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_scrolling, menu);
return true;
}

@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
Fragment fragment = null;

switch (checkedId) {
case R.id.showNestedMap:
fragment = SupportNestedScrollMapFragment.newInstance(mapOptions);
break;

case R.id.showRegularMap:
fragment = SupportMapFragment.newInstance(mapOptions);
break;
}

getSupportFragmentManager().beginTransaction()
.replace(R.id.contentFragment, fragment, null)
.commit();
}

}
11 changes: 11 additions & 0 deletions sample/src/main/res/drawable/toggle_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false" android:drawable="@color/toggle_hover" />
<item android:state_checked="false" android:state_window_focused="false" android:drawable="@color/toggle_normal" />
<item android:state_checked="true" android:state_pressed="true" android:drawable="@color/toggle_active" />
<item android:state_checked="false" android:state_pressed="true" android:drawable="@color/toggle_active" />
<item android:state_checked="true" android:state_focused="true" android:drawable="@color/toggle_hover" />
<item android:state_checked="false" android:state_focused="true" android:drawable="@color/toggle_normal_off" />
<item android:state_checked="false" android:drawable="@color/toggle_normal" />
<item android:state_checked="true" android:drawable="@color/toggle_hover" />
</selector>
83 changes: 83 additions & 0 deletions sample/src/main/res/layout/activity_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="gs.utils.maps.nestedscroll.demo.DemoActivity">

<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed|enterAlways">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<android.support.v4.widget.NestedScrollView
android:id="@+id/contentFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|center_horizontal"
app:cardCornerRadius="4dp"
app:cardElevation="4dp">

<RadioGroup
android:id="@+id/groupMapType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<RadioButton
android:id="@+id/showNestedMap"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/text_mapfragment_nested" />

<RadioButton
android:id="@+id/showRegularMap"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/text_mapfragment_regular" />

</RadioGroup>

</android.support.v7.widget.CardView>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"
app:srcCompat="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>
12 changes: 12 additions & 0 deletions sample/src/main/res/menu/menu_scrolling.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="gs.utils.maps.nestedscroll.ScrollingActivity">

<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />

</menu>
13 changes: 13 additions & 0 deletions sample/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>

<color name="toggle_hover">#808080</color>
<color name="toggle_normal">#DCdCdC</color>
<color name="toggle_active">#C0C0C0</color>
<color name="toggle_normal_off">#a9a9a9</color>

</resources>
6 changes: 6 additions & 0 deletions sample/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<dimen name="app_bar_height">180dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="text_margin">16dp</dimen>
<dimen name="margin">6dp</dimen>
</resources>
Loading

0 comments on commit 338f83c

Please sign in to comment.