Skip to content

Commit

Permalink
Playing with experimental Method to replace a given view group with t…
Browse files Browse the repository at this point in the history
…he sliding panel layout to arbitrarily add that gesture functionality to it
  • Loading branch information
r0adkll committed Jul 27, 2015
1 parent 10b65b0 commit f06860a
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ android {

}
}

lintOptions {
abortOnError false
}

}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion example/example.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":example" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="Slidr" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":example" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="SlidableActivity" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down
3 changes: 2 additions & 1 deletion library/library.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":library" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="Slidr" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":library" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="SlidableActivity" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -65,6 +65,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
Expand Down
70 changes: 70 additions & 0 deletions library/src/main/java/com/r0adkll/slidr/Slidr.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,74 @@ public void unlock() {

}

/**
* Replace a viewgroup with the sliding mechanism
*
* @param view
* @param config
* @return
*/
public static SlidrInterface replace(final ViewGroup view, final SlidrConfig config){

ViewGroup parent = (ViewGroup)view.getParent();
ViewGroup.LayoutParams params = view.getLayoutParams();
parent.removeView(view);

// Setup the slider panel and attach it to the decor
final SliderPanel panel = new SliderPanel(view.getContext(), view, config);
panel.setId(view.getId());
view.setId(R.id.slidable_panel);
panel.addView(view);
parent.addView(panel, params);

// Set the panel slide listener for when it becomes closed or opened
panel.setOnPanelSlideListener(new SliderPanel.OnPanelSlideListener() {

@Override
public void onStateChanged(int state) {
if(config.getListener() != null){
config.getListener().onSlideStateChanged(state);
}
}

@Override
public void onClosed() {
if(config.getListener() != null){
config.getListener().onSlideClosed();
}
}

@Override
public void onOpened() {
if(config.getListener() != null){
config.getListener().onSlideOpened();
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onSlideChange(float percent) {
if(config.getListener() != null){
config.getListener().onSlideChange(percent);
}
}
});

// Setup the lock interface
SlidrInterface slidrInterface = new SlidrInterface() {
@Override
public void lock() {
panel.lock();
}

@Override
public void unlock() {
panel.unlock();
}
};

// Return the lock interface
return slidrInterface;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ public void run() {
*
*/


@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
boolean interceptForDrag;
Expand Down
4 changes: 2 additions & 2 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Thu Jun 18 17:49:23 EDT 2015
sdk.dir=/Users/drew.heavner/android-sdk
#Sun Jul 26 22:32:40 EDT 2015
sdk.dir=/Users/r0adkll/Documents/Developer/android-sdk

0 comments on commit f06860a

Please sign in to comment.