-
-
Save hesling/c369d7eef71bbba74912 to your computer and use it in GitHub Desktop.
Revisions
-
blackcj revised this gist
Jun 11, 2015 . 3 changed files with 50 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#AB47BC</color> <color name="colorPrimaryDark">#9c27b0</color> <color name="colorAccent">#4E5D74</color> <color name="colorTextPrimary">#353F50</color> <color name="colorWhite">#FFFFFF</color> <color name="lightGray">#eee</color> </resources> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="200dp" android:background="@color/colorWhite" android:layout_margin="5dp"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorPrimary" android:id="@+id/container"> <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"/> </FrameLayout> </FrameLayout> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ <resources> <!-- Base application theme. --> <style name="AppTheme" parent="AppTheme.Base"> <!-- Customize your theme here. --> </style> <style name="AppTheme.Base" parent="Theme.AppCompat.NoActionBar"> <item name="colorPrimary">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:textColorPrimary">@color/colorWhite</item> <item name="android:windowNoTitle">true</item> <item name="windowActionBar">false</item> </style> <style name="Log" parent="AppTheme"> <item name="android:typeface">monospace</item> <item name="android:padding">@dimen/margin_medium</item> <item name="android:textAppearance">?android:textAppearanceMedium</item> <item name="android:lineSpacingMultiplier">1.1</item> </style> </resources> -
blackcj created this gist
Jun 11, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ import android.os.Bundle; import android.support.design.widget.AppBarLayout; import android.support.design.widget.TabLayout; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import android.util.Log; import com.blackcj.designsupportexample.adapters.RecyclerViewAdapter; public class MainActivity extends AppCompatActivity implements AppBarLayout.OnOffsetChangedListener { private AppBarLayout appBarLayout; private TabLayout tabLayout; private SwipeRefreshLayout mSwipeRefreshLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler); recyclerView.setLayoutManager(new GridLayoutManager(this, 2)); RecyclerViewAdapter adapter = new RecyclerViewAdapter(); recyclerView.setAdapter(adapter); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.contentView); mSwipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary); mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mSwipeRefreshLayout.setRefreshing(false); } }); appBarLayout = (AppBarLayout) findViewById(R.id.appBarLayout); } @Override public void onOffsetChanged(AppBarLayout appBarLayout, int i) { if (i == 0) { mSwipeRefreshLayout.setEnabled(true); } else { mSwipeRefreshLayout.setEnabled(false); } } @Override protected void onResume() { super.onResume(); appBarLayout.addOnOffsetChangedListener(this); } @Override protected void onPause() { super.onPause(); appBarLayout.removeOnOffsetChangedListener(this); } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.TextView; import com.blackcj.designsupportexample.R; /** * Created by chris.black on 6/11/15. */ public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> implements View.OnClickListener { @Override public int getItemCount() { return 10; } @Override public void onClick(final View v) { } @Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.grid_item, parent, false); v.setOnClickListener(this); return new ViewHolder(v); } @Override public void onBindViewHolder(ViewHolder holder, int position) { holder.text.setText("Test"); } protected static class ViewHolder extends RecyclerView.ViewHolder { public TextView text; public FrameLayout container; public ViewHolder(View itemView) { super(itemView); text = (TextView) itemView.findViewById(R.id.text); container = (FrameLayout) itemView.findViewById(R.id.container); } } } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <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:id="@+id/coordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:background="@color/lightGray"> <android.support.v4.widget.SwipeRefreshLayout app:layout_behavior="@string/appbar_scrolling_view_behavior" android:id="@+id/contentView" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/recycler" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v4.widget.SwipeRefreshLayout> <include layout="@layout/toolbar"/> </android.support.design.widget.CoordinatorLayout> This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "com.blackcj.designsupportexample" minSdkVersion 18 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:design:22.2.0' compile 'com.android.support:recyclerview-v7:22.2.0' } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.AppBarLayout android:id="@+id/appBarLayout" android:layout_width="match_parent" android:layout_height="wrap_content" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|enterAlways" android:background="?attr/colorPrimaryDark"/> <android.support.design.widget.TabLayout android:id="@+id/tabLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/colorPrimaryDark"/> </android.support.design.widget.AppBarLayout>