public void removeTopic() { /** Update to Database * */ ContentValues values = new ContentValues(); // values.put(DBSchema.ItemSchema.COLUMN_UPDATE_DATE,(new Date()).getTime()); values.put(DBSchema.ItemSchema.COLUMN_PATH_FILE, ""); values.put(DBSchema.ItemSchema.COLUMN_FAV, DBSchema.OFF); values.put(DBSchema.ItemSchema.COLUMN_CUR_PAGE, 0); if (Constants.FEED_TYPE_BORAD_100_NEW.equalsIgnoreCase(feedType) || Constants.FEED_TYPE_BORAD_100.equalsIgnoreCase(feedType)) { // old data have 2 record // mDbFeedAdapter.updateItem(currentItem.getId(), values); mDbFeedAdapter.updateItemByTitle(currentItem.getTitle(), values); } else { mDbFeedAdapter.updateItem(currentItem.getId(), values); } /* log.debug("before item id["+currentItem.getId()+"]title["+currentItem.getTitle()+"],fav["+currentItem.isFav()+"]"); //recheck Item currentItemTest = mDbFeedAdapter.getItem(currentItem.getId()); log.debug("after item id["+currentItemTest.getId()+"]title["+currentItemTest.getTitle()+"],fav["+currentItemTest.isFav()+"]"); */ String msg = "Remove topic success"; Toast.makeText(FeedMainItemLocalActivity.this, msg, Toast.LENGTH_LONG).show(); // Refresh ListView refreshListAllView(currentDateSort); }
// Onhold Long touch for delete public boolean onItemLongClick(AdapterView<?> arg0, View v, int pos, long id) { /* mDbFeedAdapter = new DBAdapter(this,currentFeedId,null); mDbFeedAdapter.open();*/ currentItem = mDbFeedAdapter.getItem(id); // For Show Control remove topic dispControlOnLongTouchItemInListView(); return true; }
// Click Item View Content public void onItemClick(AdapterView<?> parent, View v, int position, long id) { arrayItemAdapter.setSelectItem(position); arrayItemAdapter.notifyDataSetChanged(); listViewIndex = localViewList.getFirstVisiblePosition(); View v2 = localViewList.getChildAt(0); listViewTop = (v2 == null) ? 0 : v2.getTop(); log.debug("OnItemClick:listViewIndex[" + listViewIndex + "]listViewTop[" + listViewTop + "]"); Item item = mDbFeedAdapter.getItem(id); if ("".equals(Utils.isNull(item.getFeedType()))) { item.setFeedType(feedType); } log.debug("FeedType:" + item.getFeedType()); Feed currentFeed = mDbFeedAdapter.getFeedNoItem(item.getFeedId(), feedType); // new Feed(); // currentFeed.setType(feedType); // currentFeed.setTitle(feedTitle); new StartNewActivityInThread( dialog, currentFeed, item, topicCurPage, listViewIndex, listViewTop) .run(); }
private void refreshListAllView(String dateSort) { log.debug("refreshListAllView:" + dateSort); Control control = ControlHelper.getControlContent(this, currentFontSize, currentBgColor, topicCurPage); // init get Item All to ArList allLocalList = mDbFeedAdapter.getItems( Constants.MAX_ITEMS, "FAV_BY_FEED_TYPE_NO_DUP", dateSort, null, feedType, null); log.debug("allLocalList Size:" + allLocalList.size()); arrayItemAdapter = new FeedMainItemAdapter(this, R.id.title, allLocalList, control); localViewList.setAdapter(arrayItemAdapter); // restore scroll popsition if (listViewIndex != 0 && listViewTop != 0) { localViewList.setSelectionFromTop(listViewIndex, listViewTop); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Load Phone Preperty phoneProperty = new PhoneProperty(this); // log.debug("FeedMainItemLocalActivity:OnCreate"); // Load Setting SharedPreferencesHelper settingS = new SharedPreferencesHelper(this); currentFontSize = settingS.getSetting("textSize", "18"); userName = Utils.isNull(settingS.getSetting("username", "")); password = Utils.isNull(settingS.getSetting("password", "")); // log.debug("currentFontSize:"+currentFontSize); // log.debug("userName:["+userName+"]"); // log.debug("password:["+password+"]"); /** Set Custom Title Bar * */ customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.swipe_main_item_layout); Bundle extras = getIntent().getExtras(); // Case Pass Param From Another Activity if (extras != null) { feedTitle = Utils.isNull(extras.getString("FEED_TITLE")); feedType = Utils.isNull(extras.getString("FEED_TYPE")); topicCurPage = extras.getInt("TOPIC_CUR_PAGE"); appConfig = (AppConfig) extras.get("APP_CONFIG_MAP"); listViewIndex = extras.getInt("listViewIndex"); listViewTop = extras.getInt("listViewTop"); // log.debug("feedType["+feedType+"]"); // log.debug("feedTitle["+feedTitle+"]"); customTitleBar(feedTitle); } String[] names = new String[1]; if (Constants.FEED_TYPE_BORAD.equalsIgnoreCase(feedType)) { names[0] = "MyBookmark"; } else { names[0] = "MyLocal"; } viewFlow = (ExtViewFlow) findViewById(R.id.viewflow); adapter = new ExtDiffItemLocalViewAdapter(this, names); viewFlow.setAdapter(adapter); ExtTitleFlowIndicator indicator = (ExtTitleFlowIndicator) findViewById(R.id.viewflowindic); indicator.setTitleProvider(adapter); viewFlow.setFlowIndicator(indicator); /** Open DataBase * */ mDbFeedAdapter = new DBAdapter(this, currentFeedId, null); mDbFeedAdapter.open(); /** FooterView Load more item * */ footerView = ((LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.listfooter, null, false); /** Set Back Button * */ backBtn = (Button) findViewById(R.id.controlBackBtn); controlMoreControlBtn = (Button) findViewById(R.id.controlConfigBtn); controlRefreshBtn = (Button) findViewById(R.id.controlRefreshBtn); backBtn.setOnClickListener(this); controlMoreControlBtn.setOnClickListener(this); controlRefreshBtn.setOnClickListener(this); /** ********** Set Local*********************************************** */ localViewList = (ListView) findViewById(R.id.feed_local_list); // register itemListener localViewList.setOnItemClickListener(this); localViewList.setOnItemLongClickListener(this); /** ******************************************************** */ // Add Data to ListView refreshListAllView(currentDateSort); }
@Override protected void onDestroy() { super.onDestroy(); mDbFeedAdapter.close(); }