Skip to content

Commit

Permalink
Merge dynamic column count example with StaggeredGridActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Driller committed Feb 2, 2014
1 parent b1108ae commit c7882ed
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 142 deletions.
1 change: 0 additions & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

<activity android:name=".StaggeredGridActivity"/>
<activity android:name=".StaggeredGridEmptyViewActivity" />
<activity android:name=".StaggeredGridDynamicActivity" />
<activity android:name=".ListViewActivity"/>

</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ protected void onCreate(Bundle savedInstanceState) {

findViewById(R.id.btn_sgv).setOnClickListener(this);
findViewById(R.id.btn_sgv_empty_view).setOnClickListener(this);
findViewById(R.id.btn_sgv_dynamic).setOnClickListener(this);
findViewById(R.id.btn_listview).setOnClickListener(this);
}

Expand All @@ -28,9 +27,6 @@ public void onClick(final View v) {
else if (v.getId() == R.id.btn_sgv_empty_view) {
startActivity(new Intent(this, StaggeredGridEmptyViewActivity.class));
}
else if (v.getId() == R.id.btn_sgv_dynamic) {
startActivity(new Intent(this, StaggeredGridDynamicActivity.class));
}
else if (v.getId() == R.id.btn_listview) {
startActivity(new Intent(this, ListViewActivity.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ public SampleAdapter(final Context context, final int textViewResourceId) {
mBackgroundColors.add(R.color.grey);
}

@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
sPositionHeightRatios.clear();
}

@Override
public View getView(final int position, View convertView, final ViewGroup parent) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AdapterView;
Expand Down Expand Up @@ -66,6 +68,28 @@ protected void onCreate(Bundle savedInstanceState) {
mGridView.setOnItemClickListener(this);
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.col1:
mGridView.setColumnCount(1, 1);
break;
case R.id.col2:
mGridView.setColumnCount(2, 2);
break;
case R.id.col3:
mGridView.setColumnCount(3, 3);
break;
}
return true;
}

@Override
protected void onSaveInstanceState(final Bundle outState) {
super.onSaveInstanceState(outState);
Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@
android:layout_margin="16dp"
android:text="Staggered Grid View with Empty View" />

<Button
android:id="@+id/btn_sgv_dynamic"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="16dp"
android:layout_margin="16dp"
android:text="Staggered Grid View with dynamic column count" />

<Button
android:id="@+id/btn_listview"
android:layout_width="match_parent"
Expand Down

0 comments on commit c7882ed

Please sign in to comment.