-
Notifications
You must be signed in to change notification settings - Fork 617
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
1 parent
72e3626
commit f933db6
Showing
6 changed files
with
115 additions
and
2 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
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/github/rubensousa/recyclerviewsnap/GridActivity.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,59 @@ | ||
package com.github.rubensousa.recyclerviewsnap; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.Gravity; | ||
|
||
import com.github.rubensousa.gravitysnaphelper.GravitySnapHelper; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
public class GridActivity extends AppCompatActivity { | ||
|
||
private RecyclerView mRecyclerView; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_grid); | ||
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); | ||
|
||
Adapter adapter = new Adapter(false, false, getApps()); | ||
|
||
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 2)); | ||
mRecyclerView.setHasFixedSize(true); | ||
mRecyclerView.setAdapter(adapter); | ||
new GravitySnapHelper(Gravity.TOP).attachToRecyclerView(mRecyclerView); | ||
} | ||
|
||
private List<App> getApps() { | ||
List<App> apps = new ArrayList<>(); | ||
apps.add(new App("Google+", R.drawable.ic_google_48dp, 4.6f)); | ||
apps.add(new App("Gmail", R.drawable.ic_gmail_48dp, 4.8f)); | ||
apps.add(new App("Inbox", R.drawable.ic_inbox_48dp, 4.5f)); | ||
apps.add(new App("Google Keep", R.drawable.ic_keep_48dp, 4.2f)); | ||
apps.add(new App("Google Drive", R.drawable.ic_drive_48dp, 4.6f)); | ||
apps.add(new App("Hangouts", R.drawable.ic_hangouts_48dp, 3.9f)); | ||
apps.add(new App("Google Photos", R.drawable.ic_photos_48dp, 4.6f)); | ||
apps.add(new App("Messenger", R.drawable.ic_messenger_48dp, 4.2f)); | ||
apps.add(new App("Sheets", R.drawable.ic_sheets_48dp, 4.2f)); | ||
apps.add(new App("Slides", R.drawable.ic_slides_48dp, 4.2f)); | ||
apps.add(new App("Docs", R.drawable.ic_docs_48dp, 4.2f)); | ||
apps.add(new App("Google+", R.drawable.ic_google_48dp, 4.6f)); | ||
apps.add(new App("Gmail", R.drawable.ic_gmail_48dp, 4.8f)); | ||
apps.add(new App("Inbox", R.drawable.ic_inbox_48dp, 4.5f)); | ||
apps.add(new App("Google Keep", R.drawable.ic_keep_48dp, 4.2f)); | ||
apps.add(new App("Google Drive", R.drawable.ic_drive_48dp, 4.6f)); | ||
apps.add(new App("Hangouts", R.drawable.ic_hangouts_48dp, 3.9f)); | ||
apps.add(new App("Google Photos", R.drawable.ic_photos_48dp, 4.6f)); | ||
apps.add(new App("Messenger", R.drawable.ic_messenger_48dp, 4.2f)); | ||
apps.add(new App("Sheets", R.drawable.ic_sheets_48dp, 4.2f)); | ||
apps.add(new App("Slides", R.drawable.ic_slides_48dp, 4.2f)); | ||
apps.add(new App("Docs", R.drawable.ic_docs_48dp, 4.2f)); | ||
return apps; | ||
} | ||
} |
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
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,30 @@ | ||
<?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" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:fitsSystemWindows="true"> | ||
|
||
|
||
<android.support.v7.widget.RecyclerView | ||
android:id="@+id/recyclerView" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> | ||
|
||
|
||
<android.support.design.widget.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:theme="@style/AppTheme.AppBarOverlay"> | ||
|
||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="?actionBarSize" | ||
app:popupTheme="@style/AppTheme.PopupOverlay" | ||
app:title="@string/app_name" /> | ||
|
||
</android.support.design.widget.AppBarLayout> | ||
|
||
</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
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