Skip to content

Commit

Permalink
add test case menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhesk committed Sep 15, 2016
1 parent c468df0 commit ce80e3a
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 43 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/.idea/workspace.xml
.DS_Store
/build
local.properties
.idea
*/*.iml
40 changes: 17 additions & 23 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.github.learn.refreshandload">
xmlns:tools="http://schemas.android.com/tools"
package="com.github.learn.refreshandload">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="false"
Expand All @@ -14,7 +14,7 @@
android:theme="@style/AppTheme"
tools:replace="allowBackup">
<activity
android:name="com.github.learn.refreshandload.MainActivity"
android:name="com.github.learn.CIndex"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<intent-filter>
Expand All @@ -23,43 +23,37 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.github.learn.refreshandload.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme" />
<activity
android:name="com.github.learn.refreshandload.gridview.GridViewActivity"
android:label="@string/label_action_label_grid_view">
</activity>
android:label="@string/label_action_label_grid_view" />
<activity
android:name="com.github.learn.refreshandload.gridview.RefreshGridViewActivity"
android:label="@string/label_action_label_refresh_grid_view">
</activity>
android:label="@string/label_action_label_refresh_grid_view" />
<activity
android:name="com.github.learn.refreshandload.RefreshRecyclerActivity"
android:label="@string/label_action_label_recycler_view">
</activity>

android:label="@string/label_action_label_recycler_view" />
<activity
android:name="com.github.learn.refreshandload.HeaderRecyclerActivity"
android:label="@string/label_action_label_header_view">
</activity>
android:label="@string/label_action_label_header_view" />
<activity
android:name="com.github.learn.stickyheaders.StickyHeadersActivity"
android:label="@string/label_action_label_sticky_header_view">
</activity>
android:label="@string/label_action_label_sticky_header_view" />
<activity
android:name="com.github.learn.expandable.ExpandableRecyclerActivity"
android:label="@string/label_action_label_expandable_view">
</activity>
android:label="@string/label_action_label_expandable_view" />
<activity
android:name="com.github.learn.index.IndexRecyclerActivity"
android:label="@string/label_action_label_index_view">
</activity>
android:label="@string/label_action_label_index_view" />
<activity
android:name="com.github.learn.staggeredgrid.StaggeredGridRecyclerActivity"
android:label="@string/label_action_label_staggered_grid_view">
</activity>
android:label="@string/label_action_label_staggered_grid_view" />
<activity
android:name="com.github.learn.databinding.DataBindingRecyclerActivity"
android:label="@string/label_action_label_data_binding">
</activity>
android:label="@string/label_action_label_data_binding" />
</application>

</manifest>
87 changes: 87 additions & 0 deletions app/src/main/java/com/github/learn/CIndex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.github.learn;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.github.learn.databinding.DataBindingRecyclerActivity;
import com.github.learn.expandable.ExpandableRecyclerActivity;
import com.github.learn.index.IndexRecyclerActivity;
import com.github.learn.refreshandload.HeaderRecyclerActivity;
import com.github.learn.refreshandload.R;
import com.github.learn.refreshandload.RefreshRecyclerActivity;
import com.github.learn.refreshandload.gridview.GridViewActivity;
import com.github.learn.refreshandload.gridview.RefreshGridViewActivity;
import com.github.learn.staggeredgrid.StaggeredGridRecyclerActivity;
import com.github.learn.stickyheaders.StickyHeadersActivity;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

/**
* Created by hesk on 2016/9/15.
*/

public class CIndex extends AppCompatActivity implements AdapterView.OnItemClickListener {

private ListView mList;
private LinkedHashMap<String, Class> data = new LinkedHashMap<>();
private ArrayList<Class> o = new ArrayList<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_list);
mList = (ListView) findViewById(android.R.id.list);
ArrayList<String> items = new ArrayList<>();
initList();
for (Map.Entry<String, Class> entry : data.entrySet()) {
String key = entry.getKey();
items.add(key);
o.add(entry.getValue());
}
mList.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, items));
mList.setOnItemClickListener(this);
}

public void initList() {
data.put(getString(R.string.label_action_label_header_view), HeaderRecyclerActivity.class);
data.put(getString(R.string.label_action_label_recycler_view), RefreshRecyclerActivity.class);
data.put(getString(R.string.label_action_label_grid_view), GridViewActivity.class);
data.put(getString(R.string.label_action_label_refresh_grid_view), RefreshGridViewActivity.class);
data.put(getString(R.string.label_action_label_sticky_header_view), StickyHeadersActivity.class);
data.put(getString(R.string.label_action_label_expandable_view), ExpandableRecyclerActivity.class);
data.put(getString(R.string.label_action_label_sticky_expandable_view), StickyHeadersActivity.class);
data.put(getString(R.string.label_action_label_index_view), IndexRecyclerActivity.class);
data.put(getString(R.string.label_action_label_staggered_grid_view), StaggeredGridRecyclerActivity.class);
data.put(getString(R.string.label_action_label_data_binding), DataBindingRecyclerActivity.class);
// data.put("Demo Index Recycler Activity", IndexRecyclerActivity.class);
// data.put("Viewpager Activity", ViewPagerActivity.class);
// data.put("Header Grid Footer", ViewPagerActivity.class);
}

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(this, o.get(position));
if (position == 6) {
intent.putExtra("StickyAndExpandable", true);
}

/*
if (position == 2) {
intent.putExtra(GridViewActivity.span_count, 2);
}
if (position == 3) {
intent.putExtra(GridViewActivity.span_count, 3);
}
*/
startActivity(intent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,30 @@ public class GridViewActivity extends AppCompatActivity {
private SimpleAdapter mAdapter;
private RecyclerView mRecyclerView;
private LinearLayoutWithRecyclerOnScrollListener mLoadMoreListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ac_main);
if(getSupportActionBar() != null) {
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}

mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);

mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
final GridLayoutManager layoutManager = new GridLayoutManager(this, 3);
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position) {

if(mAdapter.isContentView(position)){
if (mAdapter.isContentView(position)) {
return 1;
} else {
//full line
return layoutManager.getSpanCount();//number of columns of the grid
return layoutManager.getSpanCount();
//number of columns of the grid
}

}
});


mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.addItemDecoration(new GridItemSpacingDecoration(this, R.dimen.grid_item_spacing));
mAdapter = new SimpleAdapter(values);
Expand All @@ -73,8 +69,6 @@ public int getLoadMoreLayoutResource() {
header.setLayoutParams(new PtrFrameLayout.LayoutParams(-1, -2));
header.setPadding(0, PtrLocalDisplay.dp2px(15), 0, PtrLocalDisplay.dp2px(10));
header.setPtrFrameLayout(ptrFrameLayout);


ptrFrameLayout.setDurationToCloseHeader(1500);
ptrFrameLayout.setHeaderView(header);
ptrFrameLayout.addPtrUIHandler(header);
Expand Down Expand Up @@ -110,9 +104,7 @@ public void run() {
}
});


mLoadMoreListener = new LinearLayoutWithRecyclerOnScrollListener(layoutManager) {

@Override
public void onLoadMore(final int pagination, int pageSize) {
mRecyclerView.post(new Runnable() {
Expand All @@ -121,8 +113,6 @@ public void run() {
mAdapter.showLoadMoreView();
}
});


mRecyclerView.postDelayed(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void onClick(View v, int position) {
default:
Toast.makeText(v.getContext(), "on click " + position, Toast.LENGTH_SHORT).show();
//mock click todo last item
//int index = (int) getItemId(position);
//remove(index);
//int CIndex = (int) getItemId(position);
//remove(CIndex);
//notifyItemRemoved(position);
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/layout/ac_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2"
cube_ptr:ptr_resistance="1.7">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_grey"
android:clickable="true"
android:orientation="vertical">


<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/main_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>

0 comments on commit ce80e3a

Please sign in to comment.