Skip to content

Commit

Permalink
feature implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Ira committed Mar 28, 2017
1 parent 77cbc7e commit 81e2178
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 85 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ buildscript {
ext.kotlin_version = '1.0.4'
repositories {
jcenter()

maven { url "https://jitpack.io" }

}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
Expand All @@ -17,7 +20,10 @@ buildscript {
allprojects {
repositories {
jcenter()

maven { url "https://jitpack.io" }
}

}

task clean(type: Delete) {
Expand Down
1 change: 1 addition & 0 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.github.igalata:Bubble-Picker:v0.1.1'
compile project(':library')
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,86 +5,37 @@
import android.support.v7.widget.AppCompatEditText;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;

import com.yalantis.jellytoolbar.listener.JellyListener;
import com.yalantis.jellytoolbar.widget.JellyToolbar;

public class MainActivity extends AppCompatActivity implements JellyListener {

private static final String TEXT_KEY = "text";

private JellyToolbar mToolbar;
private AppCompatEditText mEditText;
public class MainActivity extends AppCompatActivity {

private JellyToolbar toolbar;
private AppCompatEditText editText;
private JellyListener jellyListener = new JellyListener() {
@Override
public void onCancelIconClicked() {
if (TextUtils.isEmpty(editText.getText())) {
toolbar.collapse();
} else {
editText.getText().clear();
}
}
};

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

mToolbar = (JellyToolbar) findViewById(R.id.toolbar);
mToolbar.getToolbar().setLogo(R.drawable.ic_menu);
mToolbar.getToolbar().setPadding(0, getStatusBarHeight(), 0, 0);
mToolbar.setJellyListener(this);

mEditText = (AppCompatEditText) LayoutInflater.from(this).inflate(R.layout.edit_text, null);
mEditText.setBackgroundResource(R.color.colorTransparent);
mToolbar.setContentView(mEditText);

getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

private int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = getResources().getDimensionPixelSize(resourceId);
}
return result;
}

@Override
public void onToolbarExpandingStarted() {

}

@Override
public void onToolbarCollapsingStarted() {

}
toolbar = (JellyToolbar) findViewById(R.id.toolbar);
toolbar.getToolbar().setLogo(R.drawable.ic_menu);
toolbar.setJellyListener(jellyListener);

@Override
public void onToolbarExpanded() {

}

@Override
public void onToolbarCollapsed() {

}

@Override
public void onCancelIconClicked() {
if (TextUtils.isEmpty(mEditText.getText())) {
mToolbar.collapse();
} else {
mEditText.getText().clear();
}
}

@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString(TEXT_KEY, mEditText.getText().toString());
super.onSaveInstanceState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mEditText.setText(savedInstanceState.getString(TEXT_KEY));
mEditText.setSelection(mEditText.getText().length());
editText = (AppCompatEditText) LayoutInflater.from(this).inflate(R.layout.edit_text, null);
editText.setBackgroundResource(R.color.colorTransparent);
toolbar.setContentView(editText);
}

}
8 changes: 5 additions & 3 deletions demo/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin"
app:cancelIcon="@drawable/ic_close"
app:endColor="#8463d4"
app:endColor="@color/colorEnd"
app:icon="@drawable/ic_search"
app:startColor="#cb5ed9"
app:title=" News feed"
app:startColor="@color/colorStart"
app:title="@string/str_news_feed"
app:titleTextColor="@android:color/white" />

<ScrollView
Expand Down
2 changes: 2 additions & 0 deletions demo/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<color name="colorPrimaryDark">#8a53cf</color>
<color name="colorAccent">#FF4081</color>
<color name="colorTransparent">#00ffffff</color>
<color name="colorStart">#cb5ed9</color>
<color name="colorEnd">#8463d4</color>
</resources>
1 change: 1 addition & 0 deletions demo/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Jelly animation demo</string>
<string name="str_news_feed">News feed</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import android.view.animation.Interpolator
*/
class JellyInterpolator : Interpolator {

override fun getInterpolation(t: Float): Float {
return (Math.min(1.0, Math.sin(28 * (t - 0.22)) / (t - 0.22) / 5)).toFloat()
}
override fun getInterpolation(t: Float) = (Math.min(1.0, Math.sin(28 * t - 6.16) / (5 * t - 1.1))).toFloat()

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package com.yalantis.jellytoolbar.listener
/**
* Created by irinagalata on 11/25/16.
*/
interface JellyListener {
abstract class JellyListener {

fun onToolbarExpandingStarted()
open fun onToolbarExpandingStarted() = Unit

fun onToolbarCollapsingStarted()
open fun onToolbarCollapsingStarted() = Unit

fun onToolbarExpanded()
open fun onToolbarExpanded() = Unit

fun onToolbarCollapsed()
open fun onToolbarCollapsed() = Unit

fun onCancelIconClicked()
abstract fun onCancelIconClicked()

}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,4 @@ class JellyToolbar : FrameLayout, JellyWidget {
isExpanded = true
}

override fun init() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface JellyWidget {

fun expand()

fun init()
fun init() {}

fun expandImmediately()

Expand Down

0 comments on commit 81e2178

Please sign in to comment.