Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs that occur the most on Fabric #380

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public void onInit(int status) {
if (status != TextToSpeech.ERROR) {
mTextToSpeech.setLanguage(Locale.UK);
mTextToSpeech.setSpeechRate(0.70f);
} else {
return;
}

mTextToSpeech.setOnUtteranceCompletedListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,59 +19,14 @@ public static void terminate() {
FolioDatabaseHelper.clearInstance();
}

public static boolean insert(String table, ContentValues contentValues) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much unused code, not sure why you need it


return mDatabase.insert(table, null, contentValues) > 0;
}

public static boolean update(String table, String key, String value, ContentValues contentValues) {

return mDatabase.update(table, contentValues, key + "=?", new String[]{value}) > 0;
}

public static Cursor getHighLightsForBookId(String bookId) {
return mDatabase.rawQuery("SELECT * FROM " + HighLightTable.TABLE_NAME + " WHERE " + HighLightTable.COL_BOOK_ID + " = \"" + bookId + "\"", null);
}

public boolean deleteAll(String table) {
return mDatabase.delete(table, null, null) > 0;
}

public boolean deleteAll(String table, String whereClause, String[] whereArgs) {
return mDatabase.delete(table, whereClause + "=?", whereArgs) > 0;
}

public Cursor getAll(String table, String[] projection, String selection,
String[] selectionArgs, String orderBy) {
return mDatabase.query(table, projection, selection, selectionArgs, null, null, orderBy);
}

public Cursor getAll(String table) {
return getAll(table, null, null, null, null);
}

public Cursor get(String table, long id, String[] projection, String key) throws SQLException {
return mDatabase.query(table, projection,
key + "=?", new String[]{String.valueOf(id)}, null, null, null, null);
}

public static Cursor getAllByKey(String table, String[] projection, String key, String value) throws SQLException {
return mDatabase.query(table, projection,
key + "=?", new String[]{value}, null, null, null, null);
}

public Cursor get(String table, long id) throws SQLException {
return get(table, id, null, FolioDatabaseHelper.KEY_ID);
}

public static boolean deleteById(String table, String key, String value) {
return mDatabase.delete(table, key + "=?", new String[]{value}) > 0;
}

public Cursor getMaxId(String tableName, String key) {
return mDatabase.rawQuery("SELECT MAX(" + key + ") FROM " + tableName, null);
}

public static long saveHighLight(ContentValues highlightContentValues) {
return mDatabase.insert(HighLightTable.TABLE_NAME, null, highlightContentValues);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import com.folioreader.model.HighlightImpl
import com.folioreader.model.event.MediaOverlayPlayPauseEvent
import com.folioreader.model.locators.ReadLocator
import com.folioreader.model.locators.SearchLocator
import com.folioreader.model.sqlite.DbAdapter
import com.folioreader.ui.adapter.FolioPageFragmentAdapter
import com.folioreader.ui.adapter.SearchAdapter
import com.folioreader.ui.fragment.FolioPageFragment
Expand Down Expand Up @@ -244,6 +245,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle

// Need to add when vector drawables support library is used.
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
DbAdapter.initialize(this)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using static classes that are initialized somewhere in the lifecycle is not a good practice at all. But it will require a lot refactoring to fix everything.


handler = Handler()
val display = windowManager.defaultDisplay
Expand Down Expand Up @@ -1060,4 +1062,4 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@ class FolioPageFragment : Fragment(),

if (readLocator != null) {
val cfi = readLocator.locations.cfi
Log.v(LOG_TAG, "-> onPageFinished -> readLocator -> " + cfi!!)
mWebview!!.loadUrl(String.format(getString(R.string.callScrollToCfi), cfi))
cfi?.let {
Log.v(LOG_TAG, "-> onPageFinished -> readLocator -> $cfi")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the app need to crash if there are problems with the WebView?

mWebview!!.loadUrl(String.format(getString(R.string.callScrollToCfi), cfi))
}
} else {
loadingView!!.hide()
}
Expand Down Expand Up @@ -839,7 +841,7 @@ class FolioPageFragment : Fragment(),
if (outState != null)
outState!!.putSerializable(BUNDLE_READ_LOCATOR_CONFIG_CHANGE, lastReadLocator)
if (activity != null && !activity!!.isFinishing)
mActivityCallback!!.storeLastReadLocator(lastReadLocator)
mActivityCallback?.storeLastReadLocator(lastReadLocator)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, this is null

}
if (mWebview != null) mWebview!!.destroy()
}
Expand Down