Giter Club home page Giter Club logo

android-fly-in-app-navigation's Introduction

Note

If you use this library, please let me know at [email protected] so I can see it in action. I will also feature you in this readme so others can see it.

android-fly-in-app-navigation

This project serves as a way to implement the fly-in app navigation seen in apps like Facebook, Evernote, and Prixing.

Adding this project to your list of libraries will give you access to a new class, FanView. FanView contains two user-defined layouts that it uses to make this UI pattern. You can define the two layouts seperately just like you would define a regular layout. You then just specifiy the id's of the layouts to FanView and it will handle the animating.

You even define what elements will trigger the navigation to pop up. A simple call to FanView.showMenu() will toggle the display to pop up or close.

Features

  • Open and Closing Animations on the Main View
  • Small Open and Closing Animations on the menu to add some reality to it
  • Dropshadow on the Main View to make it appear to be over the menu
  • Smooth animation transitions for a professional, quality animation
  • Empty layouts that allow you to completely design the menu
  • Simple usage
  • Easy injection into your existing projects

Example Image

Simple Example

See this article for a more detailed explanation. http://mobilefanboy.blogspot.com/2012/06/introducing-android-fly-in-app.html

public class SampleActivity extends Activity {
  /** Called when the activity is first created. */
	private FanView fan;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        fan = (FanView) findViewById(R.id.fan_view);
        fan.setViews(R.layout.main, R.layout.fan);
    }
    
    public void unclick(View v) {
    	System.out.println("CLOSE");
    	fan.showMenu();
    }
    
    public void click(View v) {
    	System.out.println("OPEN");
    	fan.showMenu();
    }
    
}

test.xml

<?xml version="1.0" encoding="utf-8"?>
<com.deaux.fan.FanView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/com.deaux.fansample"
    android:id="@+id/fan_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" 
    app:menuSize="200dp" />

Example using Fragments

This project now supports using Fragments (support library fragments) instead of specifying layouts

public class SampleFragmentActivity extends FragmentActivity {
  /** Called when the activity is first created. */
	private FanView fan;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
        fan = (FanView) findViewById(R.id.fan_view);
        Fragment fanFrag = new MyFanFragment();
        Fragment contentFrag = new MyContentFragment();
        fan.setFragments(contentFrag, fanFrag);
    }
    
    public void unclick(View v) {
    	System.out.println("CLOSE");
    	fan.showMenu();
    }
    
    public void click(View v) {
    	System.out.println("OPEN");
    	fan.showMenu();
    }
    
}

License

Copyright 2012 Greg Billetdeaux

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

android-fly-in-app-navigation's People

Contributors

gregadeaux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-fly-in-app-navigation's Issues

setcontentview

Hi again,

Now, when i do this :

    setContentView(R.layout.menu_slider);
    fan = (FanView) findViewById(R.id.fan_view);
    fan.setViews(R.layout.activity_play, R.layout.menu_slider);

I just lose control to the activity_play widgets, right? How can i do this if imageTop is in the layout activity_play?

    top = (ImageView) findViewById(R.id.imageTop);

what is the version of sdk to develop?

i get an error from


public void setFragments(Fragment main, Fragment fan) {
        mMainView = (LinearLayout) findViewById(R.id.appView);
        mFanView = (LinearLayout) findViewById(R.id.fanView);
        mTintView = findViewById(R.id.tintView);

        FragmentManager mgr = ((FragmentActivity) getContext())
                .getSupportFragmentManager();
        mgr.beginTransaction().add(R.id.appView, main).commit();
        mgr.beginTransaction().add(R.id.fanView, fan).commit();
    }

    public void replaceMainFragment(Fragment replacement){
        FragmentManager mgr = ((FragmentActivity) getContext())
                .getSupportFragmentManager();
        mgr.beginTransaction().replace(R.id.appView, replacement).commit();
    }

i get the unsolved type from

FragmentManager mgr = ((FragmentActivity) getContext())

FanView not opening (or opening in background) upon resuming Activity

Thanks for the awesome library!

I'm running into trouble when I come back into an Activity that uses FanView. When I try to open the FanView, nothing happens. I see that FanView.showMenu() is being called and it's trying to open, but nothing opens on screen.

I'm using Fragments. I have a separate Activity for every Fragment that extends from a base Activity that does all the work of opening the FanView and setting fragments.

Interestingly, if I call mFanView.bringToFront() before mFanView.showMenu(), the FanView shows, but with the previous content Fragment.

Please help, I'm not sure where I'm going wrong.

Problem importing

Hello,

When I import existing project into workspace, i get this error and i can't do anything.
Do you have a fix?

[2012-07-24 17:35:19 - android-fly-in-app-navigation] /android-fly-in-app-navigation/gen already exists but is not a source folder. Convert to a source folder or rename it.

NullPointerException at showMenu()

I get a NullPointerException at showMenu(). mFanView, mTintMenu and mMainMenu are null when executing the sample code... Are there any sources for the sample app?

06-24 21:07:44.536: E/AndroidRuntime(858): FATAL EXCEPTION: main
06-24 21:07:44.536: E/AndroidRuntime(858): java.lang.NullPointerException
06-24 21:07:44.536: E/AndroidRuntime(858): at com.deaux.fan.FanView.showMenu(FanView.java:57)
06-24 21:07:44.536: E/AndroidRuntime(858): at de.tk.fansample.FanSampleActivity$1.onClick(FanSampleActivity.java:28)
06-24 21:07:44.536: E/AndroidRuntime(858): at android.view.View.performClick(View.java:3511)
06-24 21:07:44.536: E/AndroidRuntime(858): at android.view.View$PerformClick.run(View.java:14105)
06-24 21:07:44.536: E/AndroidRuntime(858): at android.os.Handler.handleCallback(Handler.java:605)
06-24 21:07:44.536: E/AndroidRuntime(858): at android.os.Handler.dispatchMessage(Handler.java:92)
06-24 21:07:44.536: E/AndroidRuntime(858): at android.os.Looper.loop(Looper.java:137)
06-24 21:07:44.536: E/AndroidRuntime(858): at android.app.ActivityThread.main(ActivityThread.java:4424)
06-24 21:07:44.536: E/AndroidRuntime(858): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 21:07:44.536: E/AndroidRuntime(858): at java.lang.reflect.Method.invoke(Method.java:511)
06-24 21:07:44.536: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-24 21:07:44.536: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-24 21:07:44.536: E/AndroidRuntime(858): at dalvik.system.NativeStart.main(Native Method)

Content appears in offset with a random margin when resuming from another Activity

When an item in the menu creates a new activity, upon going back, the content on the original first activity has a margin as if it was stuck in the middle of the closing animation

Solution I created a resetMargin method in the FanView class to be called in the onResume() of the affected Activities.

public void resetMargin()
{
    LayoutParams mainLayoutParams;  
    mainLayoutParams=(LayoutParams) mMainView.getLayoutParams();
    mainLayoutParams.leftMargin= 0;
    mainLayoutParams.rightMargin = 0;
}

Non-smooth animation

This works smoother:

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
    int left = (int)(mContentFromX + ((mContentToX - mContentFromX) * (Math.pow(
            interpolatedTime - 1, 5) + 1)));
    mContentView.layout(left, mContentView.getTop(), mContentView.getRight(),
            mContentView.getBottom());
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.