Search in sources :

Example 1 with StaggeredGridView

use of com.marshalchen.common.uimodule.staggeredgridview.StaggeredGridView in project UltimateAndroid by cymcsg.

the class StaggeredGridEmptyViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.staggered_grid_view_activity_sgv_empy_view);
    setTitle("SGV");
    mGridView = (StaggeredGridView) findViewById(R.id.grid_view);
    LayoutInflater layoutInflater = getLayoutInflater();
    View header = layoutInflater.inflate(R.layout.staggered_grid_view_list_item_header_footer, null);
    View footer = layoutInflater.inflate(R.layout.staggered_grid_view_list_item_header_footer, null);
    TextView txtHeaderTitle = (TextView) header.findViewById(R.id.txt_title);
    TextView txtFooterTitle = (TextView) footer.findViewById(R.id.txt_title);
    txtHeaderTitle.setText("THE HEADER!");
    txtFooterTitle.setText("THE FOOTER!");
    mGridView.addHeaderView(header);
    mGridView.addFooterView(footer);
    mGridView.setEmptyView(findViewById(android.R.id.empty));
    mAdapter = new SampleAdapter(this, R.id.txt_line1);
    // do we have saved data?
    if (savedInstanceState != null) {
        mData = savedInstanceState.getStringArrayList(SAVED_DATA_KEY);
        fillAdapter();
    }
    if (mData == null) {
        mData = SampleData.generateSampleData();
    }
    mGridView.setAdapter(mAdapter);
    mGridView.setOnItemClickListener(this);
    fetchDataReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context receiverContext, Intent receiverIntent) {
            fillAdapter();
        }
    };
    LocalBroadcastManager.getInstance(this).registerReceiver(fetchDataReceiver, new IntentFilter(FETCH_DATA_FILTER));
    fetchData();
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) AbsListView(android.widget.AbsListView) StaggeredGridView(com.marshalchen.common.uimodule.staggeredgridview.StaggeredGridView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 2 with StaggeredGridView

use of com.marshalchen.common.uimodule.staggeredgridview.StaggeredGridView in project UltimateAndroid by cymcsg.

the class StaggeredGridActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.staggered_grid_view_activity_sgv);
    setTitle("SGV");
    mGridView = (StaggeredGridView) findViewById(R.id.grid_view);
    LayoutInflater layoutInflater = getLayoutInflater();
    View header = layoutInflater.inflate(R.layout.staggered_grid_view_list_item_header_footer, null);
    View footer = layoutInflater.inflate(R.layout.staggered_grid_view_list_item_header_footer, null);
    TextView txtHeaderTitle = (TextView) header.findViewById(R.id.txt_title);
    TextView txtFooterTitle = (TextView) footer.findViewById(R.id.txt_title);
    txtHeaderTitle.setText("THE HEADER!");
    txtFooterTitle.setText("THE FOOTER!");
    mGridView.addHeaderView(header);
    mGridView.addFooterView(footer);
    mAdapter = new SampleAdapter(this, R.id.txt_line1);
    // do we have saved data?
    if (savedInstanceState != null) {
        mData = savedInstanceState.getStringArrayList(SAVED_DATA_KEY);
    }
    if (mData == null) {
        mData = SampleData.generateSampleData();
    }
    for (String data : mData) {
        mAdapter.add(data);
    }
    mGridView.setAdapter(mAdapter);
    mGridView.setOnScrollListener(this);
    mGridView.setOnItemClickListener(this);
    mGridView.setOnItemLongClickListener(this);
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AbsListView(android.widget.AbsListView) StaggeredGridView(com.marshalchen.common.uimodule.staggeredgridview.StaggeredGridView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

LayoutInflater (android.view.LayoutInflater)2 View (android.view.View)2 AbsListView (android.widget.AbsListView)2 AdapterView (android.widget.AdapterView)2 TextView (android.widget.TextView)2 StaggeredGridView (com.marshalchen.common.uimodule.staggeredgridview.StaggeredGridView)2 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1