Skip to content

Commit

Permalink
Updated Support Library, RecyclerView, Annotations, and AppCompat. Al…
Browse files Browse the repository at this point in the history
…so changed deprecated ActionBarActivity to AppCompatActivity. RecyclerView's scroll listener 'set' method was also deprecated in favor of an 'add' version. Today's Google lib updates are big.
  • Loading branch information
afollestad committed Apr 22, 2015
1 parent 3d18d3b commit f3d6a16
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 77 deletions.
4 changes: 1 addition & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.android.tools.build:gradle:1.1.3'
}
}

Expand Down
5 changes: 3 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ android {
}

dependencies {
compile 'com.android.support:support-annotations:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.android.support:support-annotations:22.1.0'
compile 'com.android.support:recyclerview-v7:22.1.0@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:support-v4:22.1.0@aar'
}

apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
24 changes: 12 additions & 12 deletions library/src/main/java/com/melnykov/fab/FloatingActionButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public FloatingActionButton(Context context, AttributeSet attrs, int defStyle) {
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int size = getDimension(
mType == TYPE_NORMAL ? R.dimen.fab_size_normal : R.dimen.fab_size_mini);
mType == TYPE_NORMAL ? R.dimen.fab_size_normal : R.dimen.fab_size_mini);
if (mShadow && !hasLollipopApi()) {
size += mShadowSize * 2;
setMarginsWithoutShadow();
Expand Down Expand Up @@ -110,13 +110,13 @@ private void initAttributes(Context context, AttributeSet attributeSet) {
if (attr != null) {
try {
mColorNormal = attr.getColor(R.styleable.FloatingActionButton_fab_colorNormal,
getColor(R.color.material_blue_500));
getColor(R.color.material_blue_500));
mColorPressed = attr.getColor(R.styleable.FloatingActionButton_fab_colorPressed,
darkenColor(mColorNormal));
darkenColor(mColorNormal));
mColorRipple = attr.getColor(R.styleable.FloatingActionButton_fab_colorRipple,
lightenColor(mColorNormal));
lightenColor(mColorNormal));
mColorDisabled = attr.getColor(R.styleable.FloatingActionButton_fab_colorDisabled,
mColorDisabled);
mColorDisabled);
mShadow = attr.getBoolean(R.styleable.FloatingActionButton_fab_shadow, true);
mType = attr.getInt(R.styleable.FloatingActionButton_fab_type, TYPE_NORMAL);
} finally {
Expand All @@ -140,7 +140,7 @@ private Drawable createDrawable(int color) {

if (mShadow && !hasLollipopApi()) {
Drawable shadowDrawable = getResources().getDrawable(mType == TYPE_NORMAL ? R.drawable.fab_shadow
: R.drawable.fab_shadow_mini);
: R.drawable.fab_shadow_mini);
LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{shadowDrawable, shapeDrawable});
layerDrawable.setLayerInset(1, mShadowSize, mShadowSize, mShadowSize, mShadowSize);
return layerDrawable;
Expand Down Expand Up @@ -184,18 +184,18 @@ private void setBackgroundCompat(Drawable drawable) {
float elevation;
if (mShadow) {
elevation = getElevation() > 0.0f ? getElevation()
: getDimension(R.dimen.fab_elevation_lollipop);
: getDimension(R.dimen.fab_elevation_lollipop);
} else {
elevation = 0.0f;
}
setElevation(elevation);
RippleDrawable rippleDrawable = new RippleDrawable(new ColorStateList(new int[][]{{}},
new int[]{mColorRipple}), drawable, null);
new int[]{mColorRipple}), drawable, null);
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
int size = getDimension(mType == TYPE_NORMAL ? R.dimen.fab_size_normal
: R.dimen.fab_size_mini);
: R.dimen.fab_size_mini);
outline.setOval(0, 0, size, size);
}
});
Expand Down Expand Up @@ -329,8 +329,8 @@ public boolean onPreDraw() {
int translationY = visible ? 0 : height + getMarginBottom();
if (animate) {
ViewPropertyAnimator.animate(this).setInterpolator(mInterpolator)
.setDuration(TRANSLATE_DURATION_MILLIS)
.translationY(translationY);
.setDuration(TRANSLATE_DURATION_MILLIS)
.translationY(translationY);
} else {
ViewHelper.setTranslationY(this, translationY);
}
Expand Down Expand Up @@ -387,7 +387,7 @@ public void attachToRecyclerView(@NonNull RecyclerView recyclerView,
scrollDetector.setScrollDirectionListener(scrollDirectionlistener);
scrollDetector.setOnScrollListener(onScrollListener);
scrollDetector.setScrollThreshold(mScrollThreshold);
recyclerView.setOnScrollListener(scrollDetector);
recyclerView.addOnScrollListener(scrollDetector);
}

public void attachToScrollView(@NonNull ObservableScrollView scrollView,
Expand Down
5 changes: 3 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ android {

dependencies {
compile project(':library')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.android.support:appcompat-v7:22.1.0@aar'
compile 'com.android.support:recyclerview-v7:22.1.0@aar'
compile 'com.android.support:support-v4:22.1.0@aar'
}
116 changes: 58 additions & 58 deletions sample/src/main/java/com/melnykov/fab/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
Expand All @@ -28,7 +28,7 @@
import com.melnykov.fab.ObservableScrollView;
import com.melnykov.fab.ScrollDirectionListener;

public class MainActivity extends ActionBarActivity {
public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -42,53 +42,53 @@ private void initActionBar() {
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.addTab(actionBar.newTab()
.setText("ListView")
.setTabListener(new ActionBar.TabListener() {
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
fragmentTransaction.replace(android.R.id.content, new ListViewFragment());
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
}));
.setText("ListView")
.setTabListener(new ActionBar.TabListener() {
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
fragmentTransaction.replace(android.R.id.content, new ListViewFragment());
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
}));
actionBar.addTab(actionBar.newTab()
.setText("RecyclerView")
.setTabListener(new ActionBar.TabListener() {
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
fragmentTransaction.replace(android.R.id.content, new RecyclerViewFragment());
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
}));
.setText("RecyclerView")
.setTabListener(new ActionBar.TabListener() {
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
fragmentTransaction.replace(android.R.id.content, new RecyclerViewFragment());
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
}));
actionBar.addTab(actionBar.newTab()
.setText("ScrollView")
.setTabListener(new ActionBar.TabListener() {
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
fragmentTransaction.replace(android.R.id.content, new ScrollViewFragment());
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
}));
.setText("ScrollView")
.setTabListener(new ActionBar.TabListener() {
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
fragmentTransaction.replace(android.R.id.content, new ScrollViewFragment());
}

@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}

@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
}));
}
}

Expand All @@ -105,15 +105,15 @@ public boolean onOptionsItemSelected(MenuItem item) {
content.setMovementMethod(LinkMovementMethod.getInstance());
content.setText(Html.fromHtml(getString(R.string.about_body)));
new AlertDialog.Builder(this)
.setTitle(R.string.about)
.setView(content)
.setInverseBackgroundForced(true)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create().show();
.setTitle(R.string.about)
.setView(content)
.setInverseBackgroundForced(true)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create().show();
}
return super.onOptionsItemSelected(item);
}
Expand All @@ -127,7 +127,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

ListView list = (ListView) root.findViewById(android.R.id.list);
ListViewAdapter listAdapter = new ListViewAdapter(getActivity(),
getResources().getStringArray(R.array.countries));
getResources().getStringArray(R.array.countries));
list.setAdapter(listAdapter);

FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fab);
Expand Down Expand Up @@ -169,7 +169,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));

RecyclerViewAdapter adapter = new RecyclerViewAdapter(getActivity(), getResources()
.getStringArray(R.array.countries));
.getStringArray(R.array.countries));
recyclerView.setAdapter(adapter);

FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.fab);
Expand Down

0 comments on commit f3d6a16

Please sign in to comment.