mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-11 00:23:58 -04:00
Java 1.7: avoid repeating data types
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
parent
6d2d6ee071
commit
4cc8aa792d
@ -41,7 +41,7 @@ public class AutoCompleteAdapter extends ArrayAdapter<String> implements Filtera
|
|||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
FilterResults filterResults = new FilterResults();
|
FilterResults filterResults = new FilterResults();
|
||||||
ArrayList<String> data = new ArrayList<String>();
|
ArrayList<String> data = new ArrayList<>();
|
||||||
if (constraint != null) {
|
if (constraint != null) {
|
||||||
// A class that queries a web API, parses the data and returns an ArrayList<Style>
|
// A class that queries a web API, parses the data and returns an ArrayList<Style>
|
||||||
try {
|
try {
|
||||||
|
@ -29,7 +29,7 @@ public class DataModel implements Parcelable {
|
|||||||
|
|
||||||
// Interface that must be implemented and provided as a public CREATOR field.
|
// Interface that must be implemented and provided as a public CREATOR field.
|
||||||
// It generates instances of our Parcelable class from a Parcel.
|
// It generates instances of our Parcelable class from a Parcel.
|
||||||
public Creator<DataModel> CREATOR = new Creator<DataModel>() {
|
public Creator<DataModel> CREATOR = new Creator<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataModel createFromParcel(Parcel source) {
|
public DataModel createFromParcel(Parcel source) {
|
||||||
|
@ -40,7 +40,7 @@ public class FileSearch {
|
|||||||
|
|
||||||
// Scan through the file system and find all the files with .zim and .zimaa extensions
|
// Scan through the file system and find all the files with .zim and .zimaa extensions
|
||||||
public ArrayList<DataModel> findFiles() {
|
public ArrayList<DataModel> findFiles() {
|
||||||
final List<String> fileList = new ArrayList<String>();
|
final List<String> fileList = new ArrayList<>();
|
||||||
FilenameFilter[] filter = new FilenameFilter[zimFiles.length];
|
FilenameFilter[] filter = new FilenameFilter[zimFiles.length];
|
||||||
|
|
||||||
// Android doesn't provide an easy way to enumerate additional sdcards
|
// Android doesn't provide an easy way to enumerate additional sdcards
|
||||||
@ -97,7 +97,7 @@ public class FileSearch {
|
|||||||
// Iterate through the file system
|
// Iterate through the file system
|
||||||
private Collection<File> listFiles(File directory, FilenameFilter[] filter, int recurse) {
|
private Collection<File> listFiles(File directory, FilenameFilter[] filter, int recurse) {
|
||||||
|
|
||||||
Vector<File> files = new Vector<File>();
|
Vector<File> files = new Vector<>();
|
||||||
|
|
||||||
File[] entries = directory.listFiles();
|
File[] entries = directory.listFiles();
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ public class FileSearch {
|
|||||||
// Create an ArrayList with our DataModel
|
// Create an ArrayList with our DataModel
|
||||||
private ArrayList<DataModel> createDataForAdapter(List<String> list) {
|
private ArrayList<DataModel> createDataForAdapter(List<String> list) {
|
||||||
|
|
||||||
ArrayList<DataModel> data = new ArrayList<DataModel>();
|
ArrayList<DataModel> data = new ArrayList<>();
|
||||||
for (String file : list) {
|
for (String file : list) {
|
||||||
|
|
||||||
data.add(new DataModel(getTitleFromFilePath(file), file));
|
data.add(new DataModel(getTitleFromFilePath(file), file));
|
||||||
|
@ -53,7 +53,7 @@ public class FileWriter {
|
|||||||
// Build a CSV list from the file paths
|
// Build a CSV list from the file paths
|
||||||
public void saveArray(ArrayList<DataModel> files) {
|
public void saveArray(ArrayList<DataModel> files) {
|
||||||
|
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
|
||||||
for (DataModel file : files) {
|
for (DataModel file : files) {
|
||||||
list.add(file.getPath());
|
list.add(file.getPath());
|
||||||
|
@ -138,7 +138,7 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private ArrayList<String> bookmarks;
|
private ArrayList<String> bookmarks;
|
||||||
|
|
||||||
private List<KiwixWebView> mWebViews = new ArrayList<KiwixWebView>();
|
private List<KiwixWebView> mWebViews = new ArrayList<>();
|
||||||
|
|
||||||
private KiwixTextToSpeech tts;
|
private KiwixTextToSpeech tts;
|
||||||
|
|
||||||
@ -1131,7 +1131,7 @@ public class KiwixMobileActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private class KiwixWebViewClient extends WebViewClient {
|
private class KiwixWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
HashMap<String, String> documentTypes = new HashMap<String, String>() {{
|
HashMap<String, String> documentTypes = new HashMap<>() {{
|
||||||
put("epub", "application/epub+zip");
|
put("epub", "application/epub+zip");
|
||||||
put("pdf", "application/pdf");
|
put("pdf", "application/pdf");
|
||||||
}};
|
}};
|
||||||
|
@ -180,7 +180,7 @@ public class KiwixTextToSpeech {
|
|||||||
tts.speak(line, TextToSpeech.QUEUE_ADD, null);
|
tts.speak(line, TextToSpeech.QUEUE_ADD, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<String, String> params = new HashMap<String, String>();
|
HashMap<String, String> params = new HashMap<>();
|
||||||
// The utterance ID isn't actually used anywhere, the param is passed only to force
|
// The utterance ID isn't actually used anywhere, the param is passed only to force
|
||||||
// the utterance listener to be notified
|
// the utterance listener to be notified
|
||||||
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "kiwixLastMessage");
|
params.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "kiwixLastMessage");
|
||||||
|
@ -115,7 +115,7 @@ public class LanguageUtils {
|
|||||||
// Read the language codes, that are supported in this app from the locales.txt file
|
// Read the language codes, that are supported in this app from the locales.txt file
|
||||||
private void getLanguageCodesFromAssets() {
|
private void getLanguageCodesFromAssets() {
|
||||||
|
|
||||||
List<String> locales = new ArrayList<String>(new FileWriter(mContext).readFileFromAssets());
|
List<String> locales = new ArrayList<>(new FileWriter(mContext).readFileFromAssets());
|
||||||
|
|
||||||
for (String locale : locales) {
|
for (String locale : locales) {
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ public class LanguageUtils {
|
|||||||
// Get a list of all the language names
|
// Get a list of all the language names
|
||||||
public List<String> getValues() {
|
public List<String> getValues() {
|
||||||
|
|
||||||
List<String> values = new ArrayList<String>();
|
List<String> values = new ArrayList<>();
|
||||||
|
|
||||||
for (LanguageContainer value : mLanguageList) {
|
for (LanguageContainer value : mLanguageList) {
|
||||||
values.add(value.getLanguageName());
|
values.add(value.getLanguageName());
|
||||||
@ -212,7 +212,7 @@ public class LanguageUtils {
|
|||||||
// Get a list of all the language codes
|
// Get a list of all the language codes
|
||||||
public List<String> getKeys() {
|
public List<String> getKeys() {
|
||||||
|
|
||||||
List<String> keys = new ArrayList<String>();
|
List<String> keys = new ArrayList<>();
|
||||||
|
|
||||||
for (LanguageContainer key : mLanguageList) {
|
for (LanguageContainer key : mLanguageList) {
|
||||||
keys.add(key.getLanguageCode());
|
keys.add(key.getLanguageCode());
|
||||||
@ -282,7 +282,7 @@ public class LanguageUtils {
|
|||||||
|
|
||||||
// Define the exceptions to the rule. The font has to be placed in the assets folder.
|
// Define the exceptions to the rule. The font has to be placed in the assets folder.
|
||||||
// Key: the language code; Value: the name of the font.
|
// Key: the language code; Value: the name of the font.
|
||||||
HashMap<String, String> exceptions = new HashMap<String, String>();
|
HashMap<String, String> exceptions = new HashMap<>();
|
||||||
exceptions.put("km", "fonts/KhmerOS.ttf");
|
exceptions.put("km", "fonts/KhmerOS.ttf");
|
||||||
exceptions.put("gu", "fonts/Lohit-Gujarati.ttf");
|
exceptions.put("gu", "fonts/Lohit-Gujarati.ttf");
|
||||||
exceptions.put("my", "fonts/Parabaik.ttf");
|
exceptions.put("my", "fonts/Parabaik.ttf");
|
||||||
|
@ -272,7 +272,7 @@ public class ZimFileSelectActivity extends AppCompatActivity
|
|||||||
// We are doing this because the CursorAdapter does not allow us do remove rows from its dataset.
|
// We are doing this because the CursorAdapter does not allow us do remove rows from its dataset.
|
||||||
private RescanDataAdapter buildArrayAdapter(Cursor cursor) {
|
private RescanDataAdapter buildArrayAdapter(Cursor cursor) {
|
||||||
|
|
||||||
ArrayList<DataModel> files = new ArrayList<DataModel>();
|
ArrayList<DataModel> files = new ArrayList<>();
|
||||||
|
|
||||||
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user