forked from IvBaranov/MaterialFavoriteButton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
1,255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
buildscript { | ||
repositories { | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath "com.android.tools.build:gradle:$GRADLE_PLUGIN_VERSION" | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion COMPILE_SDK_VERSION | ||
buildToolsVersion BUILD_TOOLS_VERSION | ||
|
||
defaultConfig { | ||
applicationId "com.github.ivbaranov.mfb.exmaple" | ||
minSdkVersion MIN_SDK_VERSION | ||
targetSdkVersion TARGET_SDK_VERSION | ||
versionCode 1 | ||
versionName VERSION_NAME | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile project(':materialfavoritebutton') | ||
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION" | ||
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION" | ||
compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /Users/ivbaranov/Documents/Android/sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.github.ivbaranov.mfb.example"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity | ||
android:name="com.github.ivbaranov.mfb.example.MainActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
84 changes: 84 additions & 0 deletions
84
example/src/main/java/com/github/ivbaranov/mfb/example/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.github.ivbaranov.mfb.example; | ||
|
||
import android.os.Bundle; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.widget.TextView; | ||
import com.github.ivbaranov.mfb.MaterialFavoriteButton; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
private TextView niceCounter; | ||
private int niceCounterValue = 37; | ||
|
||
@Override protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); | ||
setSupportActionBar(toolbar); | ||
|
||
//in the toolbar | ||
MaterialFavoriteButton toolbarFavorite = new MaterialFavoriteButton.Builder(this) // | ||
.favorite(true) | ||
.color(MaterialFavoriteButton.STYLE_WHITE) | ||
.type(MaterialFavoriteButton.STYLE_HEART) | ||
.rotationDuration(400) | ||
.create(); | ||
toolbar.addView(toolbarFavorite); | ||
toolbarFavorite.setOnFavoriteChangeListener( | ||
new MaterialFavoriteButton.OnFavoriteChangeListener() { | ||
@Override | ||
public void onFavoriteChanged(MaterialFavoriteButton buttonView, boolean favorite) { | ||
Snackbar.make(buttonView, getString(R.string.toolbar_favorite_snack) + favorite, | ||
Snackbar.LENGTH_SHORT).show(); | ||
} | ||
}); | ||
|
||
//nice cardview | ||
niceCounter = (TextView) findViewById(R.id.counter_value); | ||
niceCounter.setText(String.valueOf(niceCounterValue)); | ||
MaterialFavoriteButton materialFavoriteButtonNice = | ||
(MaterialFavoriteButton) findViewById(R.id.favorite_nice); | ||
materialFavoriteButtonNice.setFavorite(true, false); | ||
materialFavoriteButtonNice.setOnFavoriteChangeListener( | ||
new MaterialFavoriteButton.OnFavoriteChangeListener() { | ||
@Override | ||
public void onFavoriteChanged(MaterialFavoriteButton buttonView, boolean favorite) { | ||
if (favorite) { | ||
niceCounterValue++; | ||
} else { | ||
niceCounterValue--; | ||
} | ||
} | ||
}); | ||
materialFavoriteButtonNice.setOnFavoriteAnimationEndListener( | ||
new MaterialFavoriteButton.OnFavoriteAnimationEndListener() { | ||
@Override | ||
public void onAnimationEnd(MaterialFavoriteButton buttonView, boolean favorite) { | ||
niceCounter.setText(String.valueOf(niceCounterValue)); | ||
} | ||
}); | ||
} | ||
|
||
@Override public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.menu_main, menu); | ||
return true; | ||
} | ||
|
||
@Override public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
} |
Binary file added
BIN
+193 Bytes
example/src/main/res/drawable-hdpi/ic_event_available_black_24dp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.design.widget.CoordinatorLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true" | ||
tools:context=".MainActivity"> | ||
|
||
<android.support.design.widget.AppBarLayout | ||
android:layout_height="wrap_content" | ||
android:layout_width="match_parent" | ||
android:theme="@style/AppTheme.AppBarOverlay"> | ||
|
||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="?attr/colorPrimary" | ||
app:popupTheme="@style/AppTheme.PopupOverlay" /> | ||
|
||
</android.support.design.widget.AppBarLayout> | ||
|
||
<include layout="@layout/content_main" /> | ||
|
||
</android.support.design.widget.CoordinatorLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:scrollbars="none" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
tools:showIn="@layout/activity_main" | ||
tools:context=".MainActivity"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<android.support.v7.widget.CardView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/card_margin"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/text_padding" | ||
android:text="Basic" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Title" /> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/text_padding" | ||
android:text="@string/ipsum_1" /> | ||
|
||
<com.github.ivbaranov.mfb.MaterialFavoriteButton | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
</LinearLayout> | ||
|
||
</android.support.v7.widget.CardView> | ||
|
||
<android.support.v7.widget.CardView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/card_margin"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/text_padding" | ||
android:text="Nice" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Title" /> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/text_padding" | ||
android:text="@string/ipsum_en_1914_1" /> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:id="@+id/counter_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:layout_centerVertical="true" | ||
android:layout_marginLeft="@dimen/starred_margin" | ||
android:text="@string/starred" /> | ||
|
||
<TextView | ||
android:id="@+id/counter_value" | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:layout_centerVertical="true" | ||
android:layout_toRightOf="@+id/counter_text" | ||
android:layout_marginLeft="@dimen/counter_value_margin" /> | ||
|
||
<com.github.ivbaranov.mfb.MaterialFavoriteButton | ||
android:id="@+id/favorite_nice" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentRight="true" | ||
app:mfb_rotation_duration="400" | ||
app:mfb_rotation_angle="216" | ||
app:mfb_bounce_duration="700" /> | ||
|
||
</RelativeLayout> | ||
|
||
</LinearLayout> | ||
|
||
</android.support.v7.widget.CardView> | ||
|
||
|
||
<android.support.v7.widget.CardView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_margin="@dimen/card_margin"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<RelativeLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/text_padding" | ||
android:text="Custom" | ||
android:textAppearance="@style/TextAppearance.AppCompat.Title" /> | ||
|
||
<com.github.ivbaranov.mfb.MaterialFavoriteButton | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentRight="true" | ||
app:mfb_rotation_duration="700" | ||
app:mfb_rotation_angle="360" | ||
app:mfb_favorite_image="@drawable/ic_event_available_black_24dp" | ||
app:mfb_not_favorite_image="@drawable/ic_event_busy_black_24dp" | ||
app:mfb_bounce_duration="0" /> | ||
|
||
</RelativeLayout> | ||
|
||
<TextView | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="@dimen/text_padding" | ||
android:text="@string/ipsum_2" /> | ||
|
||
</LinearLayout> | ||
|
||
</android.support.v7.widget.CardView> | ||
|
||
</LinearLayout> | ||
|
||
</ScrollView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context=".MainActivity"> | ||
|
||
<item | ||
android:id="@+id/action_settings" | ||
android:title="@string/action_settings" | ||
app:showAsAction="never" /> | ||
|
||
</menu> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<resources> | ||
<style name="AppTheme.NoActionBar"> | ||
<item name="windowActionBar">false</item> | ||
<item name="windowNoTitle">true</item> | ||
</style> | ||
<style name="AppTheme.AppBarOverlay" | ||
parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> | ||
<style name="AppTheme.PopupOverlay" | ||
parent="ThemeOverlay.AppCompat.Light" /> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |
Oops, something went wrong.