Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoordinatorLayout Behavior for FooterLayout #10

Merged
merged 1 commit into from
Aug 3, 2016
Merged
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -20,5 +20,5 @@ allprojects {
}

ext {
androidSupportAppCompatV7Lib = 'com.android.support:appcompat-v7:23.1.1'
androidSupportAppCompatV7Lib = 'com.android.support:appcompat-v7:23.4.0'
}
2 changes: 1 addition & 1 deletion demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile rootProject.ext.androidSupportAppCompatV7Lib
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.1'
Expand Down
33 changes: 21 additions & 12 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bowyer.fabtransitionlayout.demo">
package="com.bowyer.fabtransitionlayout.demo">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_name">
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".BottomSheetDemoActivity"/>
<activity android:name=".FabToolBarDemoActivity"/>
<activity android:name=".BottomSheetDemoActivity" />
<activity android:name=".FabToolBarDemoActivity" />
<activity
android:name=".CoordinatorLayoutActivity"
android:label="@string/title_activity_coordinator_layout"
android:parentActivityName=".MainActivity"
android:theme="@style/AppTheme">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.bowyer.fabtransitionlayout.demo.MainActivity" />
</activity>
</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.bowyer.fabtransitionlayout.demo;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.bowyer.app.fabtransitionlayout.FooterLayout;
import com.bowyer.fabtransitionlayout.demo.adapter.RecyclerViewAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CoordinatorLayoutActivity extends AppCompatActivity {

@Bind(R.id.toolbar) Toolbar mToolbar;
@Bind(R.id.fabtoolbar) FooterLayout mFabToolbar;
@Bind(R.id.fab) FloatingActionButton mFab;
@Bind(R.id.list_view) RecyclerView mListView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_coordinator_layout);

ButterKnife.bind(this);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

initListView();
mFabToolbar.setFab(mFab);
}

private void initListView() {
List<String> list = new ArrayList<String>(100);
for (int i = 0; i < 100; i++) {
list.add("Item " + i);
}

RecyclerViewAdapter adapter = new RecyclerViewAdapter(list,this.getBaseContext());
mListView.setLayoutManager(new LinearLayoutManager(this.getBaseContext()));
mListView.setAdapter(adapter);
}

@OnClick(R.id.fab)
void onFabClick() {
mFabToolbar.expandFab();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_coordinator, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

int id = item.getItemId();

if (id == R.id.action_snackbar) {
Snackbar.make(mListView,"This is a snackbar",Snackbar.LENGTH_SHORT).show();
return true;
}

return super.onOptionsItemSelected(item);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ void startFabToolbarDemo() {
Intent intet = new Intent(this, FabToolBarDemoActivity.class);
startActivity(intet);
}
@OnClick(R.id.start_coordinator_demo)
void startCoordinatorDemo() {
Intent intet = new Intent(this, CoordinatorLayoutActivity.class);
startActivity(intet);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.bowyer.fabtransitionlayout.demo.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.RecyclerHolder> {

List<String> mList;

public RecyclerViewAdapter(List<String> list, Context context) {
this.mList = list;
}

@Override
public RecyclerViewAdapter.RecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v= LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1,parent,false);
RecyclerHolder viewHolder=new RecyclerHolder(v);
return viewHolder;
}

@Override
public void onBindViewHolder(RecyclerViewAdapter.RecyclerHolder holder, int position) {
TextView tv = (TextView) holder.itemView;
tv.setText(mList.get(position));
}

@Override
public int getItemCount() {
return mList.size();
}

public static class RecyclerHolder extends RecyclerView.ViewHolder {


public RecyclerHolder(View itemView) {
super(itemView);

}
}
}
50 changes: 50 additions & 0 deletions demo/src/main/res/layout/activity_coordinator_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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=".CoordinatorLayoutActivity">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

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

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

<android.support.v7.widget.RecyclerView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

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

<com.bowyer.app.fabtransitionlayout.FooterLayout
android:id="@+id/fabtoolbar"
android:layout_width="match_parent"
android:layout_height="56dp"
app:layout_anchor="@id/list_view"
app:layout_anchorGravity="bottom"
app:ft_container_gravity="center"
app:ft_color="@color/primary">
</com.bowyer.app.fabtransitionlayout.FooterLayout>

</android.support.design.widget.CoordinatorLayout>
5 changes: 5 additions & 0 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@
android:text="@string/bottom_sheet_demo"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/start_coordinator_demo"
android:text="@string/coordinator_demo"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</RelativeLayout>
8 changes: 8 additions & 0 deletions demo/src/main/res/menu/menu_coordinator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/action_snackbar"
android:title="@string/action_snackbar"
android:orderInCategory="1"
app:showAsAction="always"/>
</menu>
9 changes: 9 additions & 0 deletions demo/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowContentTransitions">true</item>
</style>
</resources>
1 change: 1 addition & 0 deletions demo/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<dimen name="toolbar_height">72dp</dimen>
<dimen name="menu_height">48dp</dimen>
<dimen name="menu_text_size">16sp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>
3 changes: 3 additions & 0 deletions demo/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
<string name="action_settings">Settings</string>
<string name="fab_toolbar_demo">FabToolBarDemo</string>
<string name="bottom_sheet_demo">BottomSheetDemo</string>
<string name="title_activity_coordinator_layout">Coordinator Layout</string>
<string name="coordinator_demo">Coordinator Layout Demo</string>
<string name="action_snackbar">Snackbar</string>
</resources>
4 changes: 4 additions & 0 deletions demo/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
<item name="colorAccent">@color/primary</item>
<item name="android:windowBackground">@color/window_background</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
1 change: 1 addition & 0 deletions fabtransitionlayout/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ android {
dependencies {
compile rootProject.ext.androidSupportAppCompatV7Lib
compile 'com.github.ozodrukh:CircularReveal:1.3.1'
compile 'com.android.support:design:23.4.0'
}
apply from: 'bintray-publish.gradle'
Loading