Skip to content
Open
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
16 changes: 12 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

ext {
compile_sdk_version = 26
target_sdk_version = 26
min_sdk_version = 15
build_tools_version = "27.0.3"
support_library_version = '27.1.0'
}

repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Oct 21 11:34:03 PDT 2015
#Tue Mar 20 12:09:13 CET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
16 changes: 8 additions & 8 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion compile_sdk_version
buildToolsVersion build_tools_version

defaultConfig {
minSdkVersion 15
targetSdkVersion 23
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
versionCode 1
versionName "1.0"
versionName "1.1.2"
}
buildTypes {
release {
Expand All @@ -19,7 +19,7 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation "com.android.support:recyclerview-v7:$support_library_version"
}
74 changes: 34 additions & 40 deletions library/src/main/java/com/mypopsy/widget/FloatingSearchView.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public FloatingSearchView(Context context, AttributeSet attrs, @AttrRes int defS

inflate(getContext(), R.layout.fsv_floating_search_layout, this);

mSearchInput = (LogoEditText)findViewById(R.id.fsv_search_text);
mSearchInput = (LogoEditText) findViewById(R.id.fsv_search_text);
mNavButtonView = (ImageView) findViewById(R.id.fsv_search_action_navigation);
mRecyclerView = (RecyclerView) findViewById(R.id.fsv_suggestions_list);
mDivider = findViewById(R.id.fsv_suggestions_divider);
Expand Down Expand Up @@ -183,7 +183,7 @@ private void applyXmlAttributes(AttributeSet attrs, @AttrRes int defStyleAttr, @

MarginLayoutParams dividerLP = (MarginLayoutParams) mDivider.getLayoutParams();

if(mDivider.getBackground() != null && dividerHeight != -1)
if (mDivider.getBackground() != null && dividerHeight != -1)
dividerLP.height = dividerHeight;

float maxShadowSize = mSearchBackground.getMaxShadowSize();
Expand Down Expand Up @@ -234,7 +234,7 @@ private void setupViews() {

mBackgroundDrawable = getBackground();

if(mBackgroundDrawable != null)
if (mBackgroundDrawable != null)
mBackgroundDrawable = mBackgroundDrawable.mutate();
else
mBackgroundDrawable = new ColorDrawable(DEFAULT_BACKGROUND_COLOR);
Expand All @@ -245,7 +245,7 @@ private void setupViews() {
mNavButtonView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(mNavigationClickListener != null)
if (mNavigationClickListener != null)
mNavigationClickListener.onNavigationClick();
}
});
Expand Down Expand Up @@ -295,7 +295,7 @@ public void setPopupTheme(@StyleRes int resId) {
}

public void inflateMenu(@MenuRes int menuRes) {
if(menuRes == 0) return;
if (menuRes == 0) return;
if (isInEditMode()) return;
getActivity().getMenuInflater().inflate(menuRes, mActionMenu.getMenu());

Expand Down Expand Up @@ -342,19 +342,19 @@ public void setHint(CharSequence hint) {

@Override
public void setActivated(boolean activated) {
if(activated == isActivated()) return;
if (activated == isActivated()) return;

super.setActivated(activated);

if(activated) {
if (activated) {
mSearchInput.requestFocus();
ViewUtils.showSoftKeyboardDelayed(mSearchInput, 100);
}else {
} else {
requestFocus();
ViewUtils.closeSoftKeyboard(mActivity);
}

if(mFocusListener != null)
if (mFocusListener != null)
mFocusListener.onFocusChanged(activated);

showMenu(!activated);
Expand All @@ -380,7 +380,7 @@ public void removeTextChangedListener(TextWatcher textWatcher) {

public void setAdapter(RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter) {
RecyclerView.Adapter<? extends RecyclerView.ViewHolder> old = getAdapter();
if(old != null) old.unregisterAdapterDataObserver(mAdapterObserver);
if (old != null) old.unregisterAdapterDataObserver(mAdapterObserver);
adapter.registerAdapterDataObserver(mAdapterObserver);
mRecyclerView.setAdapter(adapter);
}
Expand Down Expand Up @@ -420,7 +420,7 @@ public void showIcon(boolean show) {
}

public Drawable getIcon() {
if(mNavButtonView == null) return null;
if (mNavButtonView == null) return null;
return mNavButtonView.getDrawable();
}

Expand All @@ -437,7 +437,7 @@ protected LayoutTransition getDefaultLayoutTransition() {
private void fadeIn(boolean enter) {
ValueAnimator backgroundAnim;

if(Build.VERSION.SDK_INT >= 19)
if (Build.VERSION.SDK_INT >= 19)
backgroundAnim = ObjectAnimator.ofInt(mBackgroundDrawable, "alpha", enter ? 255 : 0);
else {
backgroundAnim = ValueAnimator.ofInt(enter ? 0 : 255, enter ? 255 : 0);
Expand All @@ -456,7 +456,7 @@ public void onAnimationUpdate(ValueAnimator animation) {

Drawable icon = unwrap(getIcon());

if(icon != null) {
if (icon != null) {
ObjectAnimator iconAnim = ObjectAnimator.ofFloat(icon, "progress", enter ? 1 : 0);
iconAnim.setDuration(backgroundAnim.getDuration());
iconAnim.setInterpolator(backgroundAnim.getInterpolator());
Expand All @@ -466,7 +466,7 @@ public void onAnimationUpdate(ValueAnimator animation) {

private int getSuggestionsCount() {
RecyclerView.Adapter<? extends RecyclerView.ViewHolder> adapter = getAdapter();
if(adapter == null) return 0;
if (adapter == null) return 0;
return adapter.getItemCount();
}

Expand All @@ -479,7 +479,7 @@ private boolean suggestionsShown() {
}

private void showSuggestions(final boolean show) {
if(show == suggestionsShown()) return;
if (show == suggestionsShown()) return;

mSuggestionsShown = show;

Expand All @@ -489,7 +489,7 @@ private void showSuggestions(final boolean show) {
final Runnable endAction = new Runnable() {
@Override
public void run() {
if(show)
if (show)
updateDivider();
else {
showDivider(false);
Expand All @@ -499,12 +499,12 @@ public void run() {
}
};

if(show) {
if (show) {
updateDivider();
mRecyclerView.setVisibility(VISIBLE);
if(mRecyclerView.getTranslationY() == 0)
if (mRecyclerView.getTranslationY() == 0)
mRecyclerView.setTranslationY(-mRecyclerView.getHeight());
}else if(childCount > 0)
} else if (childCount > 0)
translation = -mRecyclerView.getChildAt(childCount - 1).getBottom();
else
showDivider(false);
Expand All @@ -516,16 +516,16 @@ public void run() {
.withLayer()
.withEndAction(endAction);

if(show || childCount > 0)
if (show || childCount > 0)
listAnim.start();
else
endAction.run();
}

private void showDivider(boolean visible) {
mDivider.setVisibility(visible ? View.VISIBLE : View.GONE);
int shadows = TOP|LEFT|RIGHT;
if(!visible) shadows|=BOTTOM;
int shadows = TOP | LEFT | RIGHT;
if (!visible) shadows |= BOTTOM;
mSearchBackground.setShadow(shadows);
}

Expand All @@ -538,18 +538,18 @@ private Activity getActivity() {
Context context = getContext();
while (context instanceof ContextWrapper) {
if (context instanceof Activity) {
return (Activity)context;
return (Activity) context;
}
context = ((ContextWrapper)context).getBaseContext();
context = ((ContextWrapper) context).getBaseContext();
}
throw new IllegalStateException();
}

private void showMenu(final boolean visible) {
Menu menu = getMenu();
for(int i = 0; i < menu.size(); i++) {
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
if(mAlwaysShowingMenu.contains(item.getItemId())) continue;
if (mAlwaysShowingMenu.contains(item.getItemId())) continue;
item.setVisible(visible);
}
}
Expand Down Expand Up @@ -591,9 +591,9 @@ private void parseMenu(XmlPullParser parser, AttributeSet attrs)
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.MenuItem);
int itemShowAsAction = a.getInt(R.styleable.MenuItem_showAsAction, -1);

if((itemShowAsAction & MenuItem.SHOW_AS_ACTION_ALWAYS) != 0) {
if ((itemShowAsAction & MenuItem.SHOW_AS_ACTION_ALWAYS) != 0) {
int itemId = a.getResourceId(R.styleable.MenuItem_android_id, NO_ID);
if(itemId != NO_ID) mAlwaysShowingMenu.add(itemId);
if (itemId != NO_ID) mAlwaysShowingMenu.add(itemId);
}
a.recycle();
} else {
Expand Down Expand Up @@ -621,12 +621,6 @@ private void parseMenu(XmlPullParser parser, AttributeSet attrs)
}

static private Drawable unwrap(Drawable icon) {
if(icon instanceof android.support.v7.graphics.drawable.DrawableWrapper)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the part that was crashing, I'm not sure why the conditions were here, maybe you got some valid reasons, however, some of these classes/methods are not accessible anymore

return ((android.support.v7.graphics.drawable.DrawableWrapper)icon).getWrappedDrawable();
if(icon instanceof android.support.v4.graphics.drawable.DrawableWrapper)
return ((android.support.v4.graphics.drawable.DrawableWrapper)icon).getWrappedDrawable();
if(Build.VERSION.SDK_INT >= 23 && icon instanceof android.graphics.drawable.DrawableWrapper)
return ((android.graphics.drawable.DrawableWrapper)icon).getDrawable();
return DrawableCompat.unwrap(icon);
}

Expand Down Expand Up @@ -674,7 +668,7 @@ public void showLogo(boolean shown) {
}

public void setLogo(@DrawableRes int res) {
if(res == 0)
if (res == 0)
setLogo(null);
else
setLogo(ResourcesCompat.getDrawable(getResources(), res, getContext().getTheme()));
Expand All @@ -687,21 +681,21 @@ public void setLogo(Drawable logo) {

@Override
protected void onDraw(Canvas canvas) {
if(logoShown && logo != null) {
if(dirty) {
if (logoShown && logo != null) {
if (dirty) {
updateLogoBounds();
dirty = false;
}
logo.draw(canvas);
}else
} else
super.onDraw(canvas);
}

// fit center
private void updateLogoBounds() {
int logoHeight = Math.min(getHeight(), logo.getIntrinsicHeight());
int top = (getHeight() - logoHeight)/2;
int logoWidth = (logo.getIntrinsicWidth()*logoHeight)/logo.getIntrinsicHeight();
int top = (getHeight() - logoHeight) / 2;
int logoWidth = (logo.getIntrinsicWidth() * logoHeight) / logo.getIntrinsicHeight();
logo.setBounds(0, top, logoWidth, top + logoHeight);
}
}
Expand Down
35 changes: 17 additions & 18 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
compileSdkVersion compile_sdk_version
buildToolsVersion build_tools_version

defaultConfig {
applicationId "com.mypopsy.floatingsearchview.demo"
minSdkVersion 15
targetSdkVersion 23
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
versionCode 1
versionName "1.0"
buildConfigField "String", "PROJECT_URL", '"https://github.com/renaudcerrato/FloatingSearchView"'
Expand All @@ -25,30 +24,30 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':library')
// Support
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
implementation "com.android.support:appcompat-v7:$support_library_version"
implementation "com.android.support:design:$support_library_version"
// ToggleDrawable
compile 'com.github.renaudcerrato:ToggleDrawable:1.0.1'
implementation 'com.github.renaudcerrato:ToggleDrawable:1.0.1'
// Retrofit
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
compile 'com.squareup.okhttp:logging-interceptor:2.7.0'
implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2'
implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
implementation 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
implementation 'com.squareup.okhttp:logging-interceptor:2.7.0'
// RxJava
compile 'io.reactivex:rxandroid:1.1.0'
implementation 'io.reactivex:rxandroid:1.1.0'
// Dagger
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
implementation 'com.google.dagger:dagger:2.0.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2'
provided 'org.glassfish:javax.annotation:10.0-b28'
}

afterEvaluate { project ->
android.applicationVariants.each { variant ->

Task copyApk = task(("release" + variant.variantData.name.capitalize()), type:Copy) {
Task copyApk = task(("release" + variant.variantData.name.capitalize()), type: Copy) {
from variant.outputs[0].outputFile
destinationDir project.projectDir
dependsOn variant.assemble
Expand Down
Loading