Skip to content

Commit

Permalink
Fix #8 (#24)
Browse files Browse the repository at this point in the history
* Hotfix fab behaivor
  • Loading branch information
JoaquimLey authored Jan 28, 2017
1 parent fa320a7 commit dd9ff2d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#FabOptions
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FabOptions-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/4734)
[![MaterialUp](https://img.shields.io/badge/MaterialUp-FabOptions-blue.svg?style=flat)](https://material.uplabs.com/posts/faboptions)
[![Bintray](https://img.shields.io/badge/Bintray-v1.1.0-brightgreen.svg?style=flat)](https://bintray.com/joaquimleyapps/opensource/com.github.joaquimley%3Afaboptions/1.0.2)
[![Bintray](https://img.shields.io/badge/Bintray-v1.1.1-brightgreen.svg?style=flat)](https://bintray.com/leyopensource/FabOptions/com.github.joaquimley%3Afaboptions/1.1.1)
![minSdkVersion](https://img.shields.io/badge/minSdkVersion-14-green.svg?style=true)
![compileSdkVersion](https://img.shields.io/badge/compileSdkVersion-25-green.svg?style=true)

Expand All @@ -27,7 +27,7 @@ Android implementation
- Import gradle dependency:

dependencies {
compile 'com.github.joaquimley:faboptions:1.1.0'
compile 'com.github.joaquimley:faboptions:1.1.1'
}

- Add the component to your layout:
Expand Down
4 changes: 2 additions & 2 deletions faboptions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
versionCode 9
versionName "1.1.0"
versionCode 10
versionName "1.1.1"
vectorDrawables.useSupportLibrary = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,30 @@
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.widget.FrameLayout;

/**
* FabOptions component default CoordinatorLayout.Behavior to react Snackbar
*/

public class FabOptionsBehavior extends CoordinatorLayout.Behavior {
public class FabOptionsBehavior extends CoordinatorLayout.Behavior<FrameLayout> {

@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
public boolean layoutDependsOn(CoordinatorLayout parent, FrameLayout child, View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
public boolean onDependentViewChanged(CoordinatorLayout parent, FrameLayout child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
// TODO: 21/11/2016 Handle instanceof Bottomsheetnav & others
// TODO: 21/11/2016 Handle instanceof BottomSheetNav & others
return true;
}
//FabOptions component default {@link CoordinatorLayout.Behavior} to react to {@link Snackbar}

@Override
public void onDependentViewRemoved(CoordinatorLayout parent, FrameLayout child, View dependency) {
super.onDependentViewRemoved(parent, child, dependency);
child.setTranslationY(0);
}
}
8 changes: 4 additions & 4 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "com.joaquimley.faboptions.sample"
minSdkVersion 14
targetSdkVersion 25
versionCode 5
versionName "1.0.0"
versionCode 6
versionName "1.0.1"
}

buildTypes {
Expand All @@ -41,6 +41,6 @@ dependencies {
final FABOPTIONS_VERSION = '1.1.0'

compile "com.android.support:design:$DESIGN_LIBRARY_VERSION"
compile "com.github.joaquimley:faboptions:$FABOPTIONS_VERSION"
// compile project(':faboptions')
// compile "com.github.joaquimley:faboptions:$FABOPTIONS_VERSION"
compile project(':faboptions')
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class XmlSampleActivity extends AppCompatActivity implements View.OnClick
}

private Toolbar mToolbar;
private FabOptions mFabOptions;

public static Intent newStartIntent(Context context) {
return new Intent(context, XmlSampleActivity.class);
Expand All @@ -58,33 +59,32 @@ protected void onCreate(Bundle savedInstanceState) {
mToolbar = (Toolbar) findViewById(toolbar);
mToolbar.setTitle(getString(R.string.title_activity_xml));
setSupportActionBar(mToolbar);

FabOptions fabOptions = (FabOptions) findViewById(R.id.fab_options);
fabOptions.setOnClickListener(this);
if(!fabOptions.setButtonColor(R.id.faboptions_favorite, R.color.colorAccent)) {
Log.e("style button", "ERRORR");

}
mFabOptions = (FabOptions) findViewById(R.id.fab_options);
mFabOptions.setOnClickListener(this);
}

@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.faboptions_favorite:
mFabOptions.setButtonColor(R.id.faboptions_favorite, R.color.colorAccent);
Toast.makeText(XmlSampleActivity.this, "Favorite", Toast.LENGTH_SHORT).show();
break;

case R.id.faboptions_textsms:
mFabOptions.setButtonColor(R.id.faboptions_textsms, R.color.colorAccent);
Toast.makeText(XmlSampleActivity.this, "Message", Toast.LENGTH_SHORT).show();
break;


case R.id.faboptions_download:
mFabOptions.setButtonColor(R.id.faboptions_download, R.color.colorAccent);
Toast.makeText(XmlSampleActivity.this, "Download", Toast.LENGTH_SHORT).show();
break;


case R.id.faboptions_share:
mFabOptions.setButtonColor(R.id.faboptions_share, R.color.colorAccent);
Toast.makeText(XmlSampleActivity.this, "Share", Toast.LENGTH_SHORT).show();
break;

Expand Down

0 comments on commit dd9ff2d

Please sign in to comment.