Back to project page SimpleReader.
The source code is released under:
Apache License
If you think the Android project SimpleReader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dreamteam.app.ui; //w w w. j a v a 2 s .c o m import java.util.ArrayList; import java.util.List; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ImageButton; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import com.dreamteam.app.adapter.FeedCategoryAdapter; import com.dreamteam.app.config.Contants; import com.dreamteam.app.db.provider.RSSFeedCategoryProvider; import com.dreamteam.app.entity.RSSFeedCategroy; import com.dreamteam.app.utils.Logger; import com.dreateam.app.ui.R; public class FeedCategoryActivity extends BaseActivity implements LoaderManager.LoaderCallbacks<Cursor> { private ListView categoryList; private ImageButton mLeftButton; private ImageButton mRightButton; private TextView mCenterTitle; private List<RSSFeedCategroy> categories; private FeedCategoryAdapter adapter; private LoaderManager loaderManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); initProperties(); initView(); initData(); } private void initProperties() { categories = new ArrayList<RSSFeedCategroy>(); adapter = new FeedCategoryAdapter(this, categories); loaderManager = getSupportLoaderManager(); } private void initView() { setContentView(R.layout.feed_category); mLeftButton = (ImageButton) findViewById(R.id.common_left_button); mRightButton = (ImageButton) findViewById(R.id.common_right_button); mCenterTitle = (TextView) findViewById(R.id.common_center_text); categoryList = (ListView) findViewById(R.id.feed_category_lsit); mCenterTitle.setText(R.string.feed_center); mRightButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(FeedCategoryActivity.this, "???????", Toast.LENGTH_SHORT).show(); } }); mLeftButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { finish(); } }); categoryList.setAdapter(adapter); categoryList.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent intent = new Intent(); intent.putExtra("tname", categories.get(position).getTname()); intent.setClass(FeedCategoryActivity.this, CategoryDetailActivity.class); FeedCategoryActivity.this.startActivity(intent); } }); } private void initData() { loaderManager.initLoader(Contants.LOADER_CATEGORY, null, this); } // ///////////////////// load manager ////////////////////////////////// @Override public Loader<Cursor> onCreateLoader(int id, Bundle data) { Logger.debug("tangl", "start loader manager"); Uri uri = Uri .parse("content://com.dreateam.app.ui.provider.category/categories"); CursorLoader loader = new CursorLoader(this, uri, null, null, null, null); return loader; } @Override public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { Logger.debug("tangl", "finish loader manager"); if (cursor != null) { while (cursor.moveToNext()) { RSSFeedCategroy category = new RSSFeedCategroy(); category.setId((cursor.getInt(cursor .getColumnIndex(RSSFeedCategoryProvider.KEY_ID)))); category.setTitle(cursor.getString(cursor .getColumnIndex(RSSFeedCategoryProvider.KEY_TITLE))); category.setTname(cursor.getString(cursor .getColumnIndex(RSSFeedCategoryProvider.KEY_TABLE))); category.setDescription(cursor.getString(cursor .getColumnIndex(RSSFeedCategoryProvider.KEY_DESCRIPTION))); category.setImagUrl(cursor.getString(cursor .getColumnIndex(RSSFeedCategoryProvider.KEY_IMAGEURL))); categories.add(category); } } cursor.close(); Logger.debug("tangl", categories.size() + ""); adapter.bindData(categories); adapter.notifyDataSetChanged(); } @Override public void onLoaderReset(Loader<Cursor> loader) { } // ///////////////////// load manager end ////////////////////////////////// }