Two space indentation

This commit is contained in:
Isaac 2016-04-03 13:08:33 +03:00
parent c83655d29c
commit 1fd4c9d0ea
2 changed files with 153 additions and 155 deletions

View File

@ -11,16 +11,15 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
public class DatabaseHelper extends SQLiteOpenHelper { public class DatabaseHelper extends SQLiteOpenHelper {
public static final String DATABASE_NAME = "Kiwix.db"; public static final String DATABASE_NAME = "Kiwix.db";
public static final String CONTACTS_TABLE_NAME = "recentsearches"; public static final String CONTACTS_TABLE_NAME = "recentsearches";
public static final String CONTACTS_COLUMN_ID = "id"; public static final String CONTACTS_COLUMN_ID = "id";
public static final String CONTACTS_COLUMN_SEARCH = "search"; public static final String CONTACTS_COLUMN_SEARCH = "search";
public DatabaseHelper(Context context) public DatabaseHelper(Context context) {
{ super(context, DATABASE_NAME, null, 1);
super(context, DATABASE_NAME , null, 1);
} }
@Override @Override
@ -39,8 +38,7 @@ import java.util.HashMap;
onCreate(db); onCreate(db);
} }
public boolean insertSearch (String search) public boolean insertSearch(String search) {
{
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues(); ContentValues contentValues = new ContentValues();
contentValues.put(CONTACTS_COLUMN_SEARCH, search); contentValues.put(CONTACTS_COLUMN_SEARCH, search);
@ -48,40 +46,38 @@ import java.util.HashMap;
return true; return true;
} }
public Cursor getData(int id){ public Cursor getData(int id) {
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select * from " + CONTACTS_TABLE_NAME + " where id="+id+"", null ); Cursor res = db.rawQuery("select * from " + CONTACTS_TABLE_NAME + " where id=" + id + "", null);
return res; return res;
} }
public int numberOfRows(){ public int numberOfRows() {
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME); int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME);
return numRows; return numRows;
} }
public Integer deleteSearches (Integer id) public Integer deleteSearches(Integer id) {
{
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
return db.delete(CONTACTS_TABLE_NAME, return db.delete(CONTACTS_TABLE_NAME,
"id = ? ", "id = ? ",
new String[] { Integer.toString(id) }); new String[]{Integer.toString(id)});
} }
public ArrayList<String> getRecentSearches() public ArrayList<String> getRecentSearches() {
{
ArrayList<String> array_list = new ArrayList<String>(); ArrayList<String> array_list = new ArrayList<String>();
//hp = new HashMap(); //hp = new HashMap();
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor res = db.rawQuery( "select * from " + CONTACTS_TABLE_NAME, null ); Cursor res = db.rawQuery("select * from " + CONTACTS_TABLE_NAME, null);
res.moveToLast(); res.moveToLast();
while(res.isBeforeFirst() == false){ while (res.isBeforeFirst() == false) {
array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_SEARCH))); array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_SEARCH)));
res.moveToPrevious(); res.moveToPrevious();
} }
return array_list; return array_list;
} }
} }

View File

@ -37,25 +37,25 @@ public class HTMLUtils {
this.mHandler = handler; this.mHandler = handler;
} }
public void initInterface(WebView webView){ public void initInterface(WebView webView) {
webView.addJavascriptInterface(new HTMLinterface(), "HTMLUtils"); webView.addJavascriptInterface(new HTMLinterface(), "HTMLUtils");
} }
class HTMLinterface class HTMLinterface {
{
int i = 0; int i = 0;
@JavascriptInterface @JavascriptInterface
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void parse(final String sectionTitle, final String element,final String id) { public void parse(final String sectionTitle, final String element, final String id) {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
if (element.equals("H1")) { if (element.equals("H1")) {
mRightListView.removeHeaderView(headerView); mRightListView.removeHeaderView(headerView);
LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate( R.layout.section_list, null ); View view = inflater.inflate(R.layout.section_list, null);
headerView = (TextView) view.findViewById( R.id.textTab ); headerView = (TextView) view.findViewById(R.id.textTab);
headerView.setText(sectionTitle); headerView.setText(sectionTitle);
headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0); headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0);
headerView.setBackgroundColor(Color.LTGRAY); headerView.setBackgroundColor(Color.LTGRAY);
@ -96,13 +96,14 @@ public class HTMLUtils {
} }
}); });
} }
@JavascriptInterface @JavascriptInterface
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void start() { public void start() {
mHandler.post(new Runnable() { mHandler.post(new Runnable() {
@Override @Override
public void run() { public void run() {
i=0; i = 0;
textViews.clear(); textViews.clear();
sectionProperties.clear(); sectionProperties.clear();
arrayAdapter.clear(); arrayAdapter.clear();
@ -110,6 +111,7 @@ public class HTMLUtils {
} }
}); });
} }
@JavascriptInterface @JavascriptInterface
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void stop() { public void stop() {