Skip to content

Commit

Permalink
Added Quick Return pattern
Browse files Browse the repository at this point in the history
Implemented using Design Support Lib
  • Loading branch information
Suleiman19 committed Jun 17, 2015
1 parent 45aca88 commit 929549b
Show file tree
Hide file tree
Showing 15 changed files with 146 additions and 30 deletions.
2 changes: 2 additions & 0 deletions MaterialSample/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/it.sephiroth.android.library.viewrevealanimator/view-reveal-animator/1.1.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
Expand All @@ -96,6 +97,7 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="recyclerview-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="palette-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="view-reveal-animator-1.1.4" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
Expand Down
1 change: 1 addition & 0 deletions MaterialSample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dependencies {
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:palette-v7:22.2.0'
compile 'it.sephiroth.android.library.viewrevealanimator:view-reveal-animator:+'
}
17 changes: 13 additions & 4 deletions MaterialSample/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.suleiman.material" >
package="com.suleiman.material">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
android:theme="@style/MyTheme">
<activity
android:name=".activities.MainActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name" >
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down Expand Up @@ -38,8 +38,17 @@
android:label="@string/title_activity_tab_animation" />
<activity
android:name=".activities.NestedToolbarActivity"
android:label="@string/title_activity_nested_toolbar" >
android:label="@string/title_activity_nested_toolbar" />
<activity
android:name=".activities.QuickReturnActivity"
android:configChanges="orientation|screenSize"
android:label="@string/title_quick_return"
android:uiOptions="splitActionBarWhenNarrow">
<meta-data
android:name="android.support.UI_OPTIONS"
android:value="splitActionBarWhenNarrow" />
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,8 @@ public void onNothingSelected(AdapterView<?> parent) {
if (simpleRecyclerAdapter == null) {
simpleRecyclerAdapter = new SimpleRecyclerAdapter(listData);
recyclerView.setAdapter(simpleRecyclerAdapter);
} else {
simpleRecyclerAdapter.notifyDataSetChanged();
}


recyclerView.addOnScrollListener(new MyRecyclerScroll() {
@Override
public void show() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public void onItemClick(View view, int position) {
intent = new Intent(MainActivity.this, NestedToolbarActivity.class);
startActivity(intent);
break;
case 6:
intent = new Intent(MainActivity.this, QuickReturnActivity.class);
startActivity(intent);
break;

default:
Toast.makeText(getBaseContext(), "Undefined Click!", Toast.LENGTH_SHORT).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected void onRestoreInstanceState(Bundle savedInstanceState) {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_nav_drawer, menu);
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.suleiman.material.activities;

import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;

import com.suleiman.material.R;
import com.suleiman.material.adapter.SimpleRecyclerAdapter;
import com.suleiman.material.model.VersionModel;

import java.util.ArrayList;
import java.util.List;

/**
* Created by Suleiman on 15-06-2015.
*/
public class QuickReturnActivity extends AppCompatActivity {
RecyclerView recyclerView;
SimpleRecyclerAdapter adapter;
CoordinatorLayout mCoordinatorLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_quick_return);

final Toolbar toolbar = (Toolbar) findViewById(R.id.quickreturn_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.quickreturn_coordinator);
recyclerView = (RecyclerView) findViewById(R.id.quickreturn_list);

recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));

List<String> listData = new ArrayList<String>();
int ct = 0;
for (int i = 0; i < VersionModel.data.length * 3; i++) {
listData.add(VersionModel.data[ct]);
ct++;
if (ct == VersionModel.data.length) {
ct = 0;
}
}

if (adapter == null) {
adapter = new SimpleRecyclerAdapter(listData);
recyclerView.setAdapter(adapter);
}


}


@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) {

switch (item.getItemId()) {
case R.id.action_settings:
return true;
case android.R.id.home:
supportFinishAfterTransition();
return true;
}

return super.onOptionsItemSelected(item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void setupViewPager(ViewPager viewPager) {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_tab_animation, menu);
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

Expand Down
29 changes: 29 additions & 0 deletions MaterialSample/app/src/main/res/layout/activity_quick_return.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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:id="@+id/quickreturn_coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.Toolbar
android:id="@+id/quickreturn_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
android:id="@+id/quickreturn_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />


</android.support.design.widget.CoordinatorLayout>
7 changes: 5 additions & 2 deletions MaterialSample/app/src/main/res/menu/menu_home_navigator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.suleiman.material.activities.MainActivity">
<item android:id="@+id/action_settings" android:title="@string/action_settings"
android:orderInCategory="100" app:showAsAction="never" />
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>
10 changes: 0 additions & 10 deletions MaterialSample/app/src/main/res/menu/menu_nav_drawer.xml

This file was deleted.

7 changes: 0 additions & 7 deletions MaterialSample/app/src/main/res/menu/menu_tab_animation.xml

This file was deleted.

6 changes: 4 additions & 2 deletions MaterialSample/app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@
<item>Toolbar Animation with Image</item>
<item>Material Style Tabs</item>
<item>Card View Toolbar</item>
<item>Quick Return Pattern</item>

</string-array>

<string-array name="home_activities_subtitle">
<item>G+ like on scroll hide animation</item>
<item>Overlaid transparent Toolbar</item>
<item>Material Design drawer with scrim</item>
<item>Using the new Support Design library</item>
<item>Tab strip with Design support lib</item>
<item>Using the new Support Design Library</item>
<item>Tab strip with Design Support Lib</item>
<item>Nested Toolbar in card</item>
<item>UI Pattern using Design Support Lib</item>

</string-array>

Expand Down
2 changes: 2 additions & 0 deletions MaterialSample/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
<string name="title_activity_nested_toolbar">Nested Toolbar</string>
<string name="action_search">Search</string>
<string name="action_view_module">View</string>
<string name="title_quick_return">Quick Return</string>
<string name="title_activity_reveal">Reveal Animation</string>
</resources>
1 change: 1 addition & 0 deletions MaterialSample/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<item name="colorPrimaryDark">@color/primary_700</item>
<item name="colorAccent">@color/accent_500</item>
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">true</item>
<item name="windowNoTitle">true</item>
<item name="android:windowBackground">@color/background_material_light</item>
</style>
Expand Down

0 comments on commit 929549b

Please sign in to comment.