Some fixes

This commit is contained in:
stom79 2018-12-28 11:38:26 +01:00
parent 6b4c77f0b8
commit bb92d6ca32
2 changed files with 17 additions and 12 deletions

View File

@ -2483,9 +2483,11 @@ public abstract class BaseMainActivity extends BaseActivity
List<TagTimeline> tagTimelines = new SearchDAO(BaseMainActivity.this, db).getTabInfo(tabName); List<TagTimeline> tagTimelines = new SearchDAO(BaseMainActivity.this, db).getTabInfo(tabName);
String tag; String tag;
if( tagTimelines == null || tagTimelines.size() == 0) if( tagTimelines == null || tagTimelines.size() == 0) {
tag = tabName; tag = tabName;
else if(tagTimelines == null)
tagTimelines = new SearchDAO(BaseMainActivity.this, db).getTimelineInfo(tag);
}else
tag = tagTimelines.get(0).getName(); tag = tagTimelines.get(0).getName();
PopupMenu popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(position)); PopupMenu popup = new PopupMenu(BaseMainActivity.this, tabStrip.getChildAt(position));
popup.getMenuInflater() popup.getMenuInflater()

View File

@ -56,13 +56,16 @@ public class SearchDAO {
*/ */
public void insertSearch(String keyword) { public void insertSearch(String keyword) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(Sqlite.COL_KEYWORDS, keyword); if( keyword != null && keyword.trim().length() > 0) {
values.put(Sqlite.COL_USER_ID, userId); values.put(Sqlite.COL_KEYWORDS, keyword.trim());
values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date())); values.put(Sqlite.COL_USER_ID, userId);
//Inserts search values.put(Sqlite.COL_DATE_CREATION, Helper.dateToString(new Date()));
try{ //Inserts search
db.insert(Sqlite.TABLE_SEARCH, null, values); try {
}catch (Exception ignored) {} db.insert(Sqlite.TABLE_SEARCH, null, values);
} catch (Exception ignored) {
}
}
} }
@ -83,7 +86,7 @@ public class SearchDAO {
if( none != null && none.size() > 0) if( none != null && none.size() > 0)
values.put(Sqlite.COL_NONE, Helper.arrayToStringStorage(none)); values.put(Sqlite.COL_NONE, Helper.arrayToStringStorage(none));
if( name != null && name.trim().length() > 0) if( name != null && name.trim().length() > 0)
values.put(Sqlite.COL_NAME, name); values.put(Sqlite.COL_NAME, name.trim());
try{ try{
db.update(Sqlite.TABLE_SEARCH, values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_KEYWORDS + " = ?", new String[]{userId, tagTimeline.getName()}); db.update(Sqlite.TABLE_SEARCH, values, Sqlite.COL_USER_ID + " = ? AND " + Sqlite.COL_KEYWORDS + " = ?", new String[]{userId, tagTimeline.getName()});
}catch (Exception ignored) {} }catch (Exception ignored) {}
@ -184,9 +187,9 @@ public class SearchDAO {
* Returns TagTimeline information by its keyword in db * Returns TagTimeline information by its keyword in db
* @return info List<TagTimeline> * @return info List<TagTimeline>
*/ */
public List<TagTimeline> getTabInfo(String keyword){ public List<TagTimeline> getTabInfo(String name){
try { try {
Cursor c = db.query(Sqlite.TABLE_SEARCH, null, Sqlite.COL_NAME + " = \"" + keyword + "\" AND " + Sqlite.COL_USER_ID + " = \"" + userId+ "\"", null, null, null, null, null); Cursor c = db.query(Sqlite.TABLE_SEARCH, null, Sqlite.COL_NAME + " = \"" + name + "\" AND " + Sqlite.COL_USER_ID + " = \"" + userId+ "\"", null, null, null, null, null);
return cursorToTagTimelineSearch(c); return cursorToTagTimelineSearch(c);
} catch (Exception e) { } catch (Exception e) {
return null; return null;