From 1fd4c9d0ea0fb7cdff654e32ade1c76d036fbe3b Mon Sep 17 00:00:00 2001 From: Isaac Date: Sun, 3 Apr 2016 13:08:33 +0300 Subject: [PATCH] Two space indentation --- .../kiwixmobile/utils/DatabaseHelper.java | 118 ++++++----- .../kiwix/kiwixmobile/utils/HTMLUtils.java | 190 +++++++++--------- 2 files changed, 153 insertions(+), 155 deletions(-) diff --git a/src/org/kiwix/kiwixmobile/utils/DatabaseHelper.java b/src/org/kiwix/kiwixmobile/utils/DatabaseHelper.java index 25f9127e9..fa3f2e398 100644 --- a/src/org/kiwix/kiwixmobile/utils/DatabaseHelper.java +++ b/src/org/kiwix/kiwixmobile/utils/DatabaseHelper.java @@ -11,77 +11,73 @@ import java.util.ArrayList; 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 CONTACTS_TABLE_NAME = "recentsearches"; - public static final String CONTACTS_COLUMN_ID = "id"; - public static final String CONTACTS_COLUMN_SEARCH = "search"; + public static final String DATABASE_NAME = "Kiwix.db"; + public static final String CONTACTS_TABLE_NAME = "recentsearches"; + public static final String CONTACTS_COLUMN_ID = "id"; + public static final String CONTACTS_COLUMN_SEARCH = "search"; - public DatabaseHelper(Context context) - { - super(context, DATABASE_NAME , null, 1); - } + public DatabaseHelper(Context context) { + super(context, DATABASE_NAME, null, 1); + } - @Override - public void onCreate(SQLiteDatabase db) { - // TODO Auto-generated method stub - db.execSQL( - "create table " + CONTACTS_TABLE_NAME + - " (id integer primary key, search text)" - ); - } + @Override + public void onCreate(SQLiteDatabase db) { + // TODO Auto-generated method stub + db.execSQL( + "create table " + CONTACTS_TABLE_NAME + + " (id integer primary key, search text)" + ); + } - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - // TODO Auto-generated method stub - db.execSQL("DROP TABLE IF EXISTS " + CONTACTS_TABLE_NAME); - onCreate(db); - } + @Override + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { + // TODO Auto-generated method stub + db.execSQL("DROP TABLE IF EXISTS " + CONTACTS_TABLE_NAME); + onCreate(db); + } - public boolean insertSearch (String search) - { - SQLiteDatabase db = this.getWritableDatabase(); - ContentValues contentValues = new ContentValues(); - contentValues.put(CONTACTS_COLUMN_SEARCH, search); - db.insert(CONTACTS_TABLE_NAME, null, contentValues); - return true; - } + public boolean insertSearch(String search) { + SQLiteDatabase db = this.getWritableDatabase(); + ContentValues contentValues = new ContentValues(); + contentValues.put(CONTACTS_COLUMN_SEARCH, search); + db.insert(CONTACTS_TABLE_NAME, null, contentValues); + return true; + } - public Cursor getData(int id){ - SQLiteDatabase db = this.getReadableDatabase(); - Cursor res = db.rawQuery( "select * from " + CONTACTS_TABLE_NAME + " where id="+id+"", null ); - return res; - } + public Cursor getData(int id) { + SQLiteDatabase db = this.getReadableDatabase(); + Cursor res = db.rawQuery("select * from " + CONTACTS_TABLE_NAME + " where id=" + id + "", null); + return res; + } - public int numberOfRows(){ - SQLiteDatabase db = this.getReadableDatabase(); - int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME); - return numRows; - } + public int numberOfRows() { + SQLiteDatabase db = this.getReadableDatabase(); + int numRows = (int) DatabaseUtils.queryNumEntries(db, CONTACTS_TABLE_NAME); + return numRows; + } - public Integer deleteSearches (Integer id) - { - SQLiteDatabase db = this.getWritableDatabase(); - return db.delete(CONTACTS_TABLE_NAME, - "id = ? ", - new String[] { Integer.toString(id) }); - } + public Integer deleteSearches(Integer id) { + SQLiteDatabase db = this.getWritableDatabase(); + return db.delete(CONTACTS_TABLE_NAME, + "id = ? ", + new String[]{Integer.toString(id)}); + } - public ArrayList getRecentSearches() - { - ArrayList array_list = new ArrayList(); + public ArrayList getRecentSearches() { + ArrayList array_list = new ArrayList(); - //hp = new HashMap(); - SQLiteDatabase db = this.getReadableDatabase(); - Cursor res = db.rawQuery( "select * from " + CONTACTS_TABLE_NAME, null ); - res.moveToLast(); + //hp = new HashMap(); + SQLiteDatabase db = this.getReadableDatabase(); + Cursor res = db.rawQuery("select * from " + CONTACTS_TABLE_NAME, null); + res.moveToLast(); - while(res.isBeforeFirst() == false){ - array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_SEARCH))); - res.moveToPrevious(); - } - return array_list; - } + while (res.isBeforeFirst() == false) { + array_list.add(res.getString(res.getColumnIndex(CONTACTS_COLUMN_SEARCH))); + res.moveToPrevious(); } + return array_list; + } +} diff --git a/src/org/kiwix/kiwixmobile/utils/HTMLUtils.java b/src/org/kiwix/kiwixmobile/utils/HTMLUtils.java index 1041845c0..5a4cad369 100644 --- a/src/org/kiwix/kiwixmobile/utils/HTMLUtils.java +++ b/src/org/kiwix/kiwixmobile/utils/HTMLUtils.java @@ -20,107 +20,109 @@ import java.util.List; public class HTMLUtils { - private List sectionProperties; - private List textViews; - private ArrayAdapter arrayAdapter; - private KiwixMobileActivity context; - private Handler mHandler; - private ListView mRightListView; - private TextView headerView; + private List sectionProperties; + private List textViews; + private ArrayAdapter arrayAdapter; + private KiwixMobileActivity context; + private Handler mHandler; + private ListView mRightListView; + private TextView headerView; - public HTMLUtils(List sectionProperties, List textViews, ListView listView, KiwixMobileActivity context, Handler handler) { - this.sectionProperties = sectionProperties; - this.textViews = textViews; - this.mRightListView = listView; - this.arrayAdapter = (ArrayAdapter) listView.getAdapter(); - this.context = context; - this.mHandler = handler; + public HTMLUtils(List sectionProperties, List textViews, ListView listView, KiwixMobileActivity context, Handler handler) { + this.sectionProperties = sectionProperties; + this.textViews = textViews; + this.mRightListView = listView; + this.arrayAdapter = (ArrayAdapter) listView.getAdapter(); + this.context = context; + this.mHandler = handler; + } + + public void initInterface(WebView webView) { + webView.addJavascriptInterface(new HTMLinterface(), "HTMLUtils"); + } + + + class HTMLinterface { + int i = 0; + + @JavascriptInterface + @SuppressWarnings("unused") + public void parse(final String sectionTitle, final String element, final String id) { + mHandler.post(new Runnable() { + @Override + public void run() { + if (element.equals("H1")) { + mRightListView.removeHeaderView(headerView); + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + View view = inflater.inflate(R.layout.section_list, null); + headerView = (TextView) view.findViewById(R.id.textTab); + headerView.setText(sectionTitle); + headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0); + headerView.setBackgroundColor(Color.LTGRAY); + headerView.setTypeface(Typeface.DEFAULT_BOLD); + headerView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + context.getCurrentWebView().setScrollY(0); + context.mRightDrawerLayout.closeDrawer(Gravity.RIGHT); + } + }); + mRightListView.addHeaderView(headerView); + } else { + textViews.add(i, new TextView(context)); + sectionProperties.add(i, new KiwixMobileActivity.SectionProperties()); + KiwixMobileActivity.SectionProperties section = sectionProperties.get(i); + section.sectionTitle = sectionTitle; + section.sectionId = id; + switch (element) { + case "H2": + section.leftPadding = (int) (30 * context.getResources().getDisplayMetrics().density); + section.typeface = Typeface.DEFAULT; + section.color = Color.BLACK; + break; + case "H3": + section.leftPadding = (int) (50 * context.getResources().getDisplayMetrics().density); + section.typeface = Typeface.DEFAULT; + section.color = Color.GRAY; + break; + default: + section.leftPadding = (int) (30 * context.getResources().getDisplayMetrics().density); + section.typeface = Typeface.DEFAULT; + section.color = Color.BLACK; + break; + } + i++; + } + } + }); } - public void initInterface(WebView webView){ - webView.addJavascriptInterface(new HTMLinterface(), "HTMLUtils"); + @JavascriptInterface + @SuppressWarnings("unused") + public void start() { + mHandler.post(new Runnable() { + @Override + public void run() { + i = 0; + textViews.clear(); + sectionProperties.clear(); + arrayAdapter.clear(); + arrayAdapter.notifyDataSetChanged(); + } + }); } - - class HTMLinterface - { - int i = 0; - @JavascriptInterface - @SuppressWarnings("unused") - public void parse(final String sectionTitle, final String element,final String id) { - mHandler.post(new Runnable() { - @Override - public void run() { - if (element.equals("H1")) { - mRightListView.removeHeaderView(headerView); - LayoutInflater inflater = (LayoutInflater) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE ); - View view = inflater.inflate( R.layout.section_list, null ); - headerView = (TextView) view.findViewById( R.id.textTab ); - headerView.setText(sectionTitle); - headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0); - headerView.setBackgroundColor(Color.LTGRAY); - headerView.setTypeface(Typeface.DEFAULT_BOLD); - headerView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - context.getCurrentWebView().setScrollY(0); - context.mRightDrawerLayout.closeDrawer(Gravity.RIGHT); - } - }); - mRightListView.addHeaderView(headerView); - } else { - textViews.add(i, new TextView(context)); - sectionProperties.add(i, new KiwixMobileActivity.SectionProperties()); - KiwixMobileActivity.SectionProperties section = sectionProperties.get(i); - section.sectionTitle = sectionTitle; - section.sectionId = id; - switch (element) { - case "H2": - section.leftPadding = (int) (30 * context.getResources().getDisplayMetrics().density); - section.typeface = Typeface.DEFAULT; - section.color = Color.BLACK; - break; - case "H3": - section.leftPadding = (int) (50 * context.getResources().getDisplayMetrics().density); - section.typeface = Typeface.DEFAULT; - section.color = Color.GRAY; - break; - default: - section.leftPadding = (int) (30 * context.getResources().getDisplayMetrics().density); - section.typeface = Typeface.DEFAULT; - section.color = Color.BLACK; - break; - } - i++; - } - } - }); - } - @JavascriptInterface - @SuppressWarnings("unused") - public void start() { - mHandler.post(new Runnable() { - @Override - public void run() { - i=0; - textViews.clear(); - sectionProperties.clear(); - arrayAdapter.clear(); - arrayAdapter.notifyDataSetChanged(); - } - }); - } - @JavascriptInterface - @SuppressWarnings("unused") - public void stop() { - mHandler.post(new Runnable() { - @Override - public void run() { - arrayAdapter.notifyDataSetChanged(); - } - }); + @JavascriptInterface + @SuppressWarnings("unused") + public void stop() { + mHandler.post(new Runnable() { + @Override + public void run() { + arrayAdapter.notifyDataSetChanged(); } + }); } + } }