some small fixes
This commit is contained in:
parent
0bfc7a9177
commit
839cd7d1c7
|
@ -68,7 +68,6 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
private Menu menu = null;
|
private Menu menu = null;
|
||||||
|
|
||||||
private SuggestionListAdapter suggestionListAdapter;
|
private SuggestionListAdapter suggestionListAdapter;
|
||||||
private StreamingService streamingService;
|
|
||||||
private SuggestionSearchRunnable suggestionSearchRunnable;
|
private SuggestionSearchRunnable suggestionSearchRunnable;
|
||||||
private Thread searchThread;
|
private Thread searchThread;
|
||||||
|
|
||||||
|
@ -152,12 +151,12 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SuggestionSearchRunnable implements Runnable{
|
private class SuggestionSearchRunnable implements Runnable{
|
||||||
private final SearchEngine engine;
|
private final int serviceId;
|
||||||
private final String query;
|
private final String query;
|
||||||
final Handler h = new Handler();
|
final Handler h = new Handler();
|
||||||
private Context context;
|
private Context context;
|
||||||
private SuggestionSearchRunnable(SearchEngine engine, String query) {
|
private SuggestionSearchRunnable(int serviceId, String query) {
|
||||||
this.engine = engine;
|
this.serviceId = serviceId;
|
||||||
this.query = query;
|
this.query = query;
|
||||||
context = VideoItemListActivity.this;
|
context = VideoItemListActivity.this;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +164,8 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
SearchEngine engine =
|
||||||
|
ServiceList.getService(serviceId).getSearchEngineInstance(new Downloader());
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
String searchLanguageKey = context.getString(R.string.search_language_key);
|
String searchLanguageKey = context.getString(R.string.search_language_key);
|
||||||
String searchLanguage = sp.getString(searchLanguageKey,
|
String searchLanguage = sp.getString(searchLanguageKey,
|
||||||
|
@ -174,7 +175,7 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
} catch (ExtractionException e) {
|
} catch (ExtractionException e) {
|
||||||
ErrorActivity.reportError(h, VideoItemListActivity.this, e, null, findViewById(R.id.videoitem_list),
|
ErrorActivity.reportError(h, VideoItemListActivity.this, e, null, findViewById(R.id.videoitem_list),
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
/* todo: this shoudl not be assigned static */ "Youtube", query, R.string.parsing_error));
|
ServiceList.getNameOfService(serviceId), query, R.string.parsing_error));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
postNewErrorToast(h, R.string.network_error);
|
postNewErrorToast(h, R.string.network_error);
|
||||||
|
@ -182,7 +183,7 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorActivity.reportError(h, VideoItemListActivity.this, e, null, findViewById(R.id.videoitem_list),
|
ErrorActivity.reportError(h, VideoItemListActivity.this, e, null, findViewById(R.id.videoitem_list),
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
/* todo: this shoudl not be assigned static */ "Youtube", query, R.string.general_error));
|
ServiceList.getNameOfService(serviceId), query, R.string.general_error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,6 +197,7 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_videoitem_list);
|
setContentView(R.layout.activity_videoitem_list);
|
||||||
|
StreamingService streamingService = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//------ todo: remove this line when multiservice support is implemented ------
|
//------ todo: remove this line when multiservice support is implemented ------
|
||||||
|
@ -205,7 +207,7 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ErrorActivity.reportError(VideoItemListActivity.this, e, null, findViewById(R.id.videoitem_list),
|
ErrorActivity.reportError(VideoItemListActivity.this, e, null, findViewById(R.id.videoitem_list),
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
/* todo: this shoudl not be assigned static */ "Youtube", "", R.string.general_error));
|
ServiceList.getNameOfService(currentStreamingServiceId), "", R.string.general_error));
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
//to solve issue 38
|
//to solve issue 38
|
||||||
|
@ -365,8 +367,7 @@ public class VideoItemListActivity extends AppCompatActivity
|
||||||
|
|
||||||
private void searchSuggestions(String query) {
|
private void searchSuggestions(String query) {
|
||||||
suggestionSearchRunnable =
|
suggestionSearchRunnable =
|
||||||
new SuggestionSearchRunnable(streamingService.getSearchEngineInstance(new Downloader()),
|
new SuggestionSearchRunnable(currentStreamingServiceId, query);
|
||||||
query);
|
|
||||||
searchThread = new Thread(suggestionSearchRunnable);
|
searchThread = new Thread(suggestionSearchRunnable);
|
||||||
searchThread.start();
|
searchThread.start();
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,15 @@ public class ServiceList {
|
||||||
public static StreamingService getService(String serviceName) throws ExtractionException {
|
public static StreamingService getService(String serviceName) throws ExtractionException {
|
||||||
return services[getIdOfService(serviceName)];
|
return services[getIdOfService(serviceName)];
|
||||||
}
|
}
|
||||||
|
public static String getNameOfService(int id) {
|
||||||
|
try {
|
||||||
|
return getService(id).getServiceInfo().name;
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Service id not known");
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
public static int getIdOfService(String serviceName) throws ExtractionException {
|
public static int getIdOfService(String serviceName) throws ExtractionException {
|
||||||
for(int i = 0; i < services.length; i++) {
|
for(int i = 0; i < services.length; i++) {
|
||||||
if(services[i].getServiceInfo().name.equals(serviceName)) {
|
if(services[i].getServiceInfo().name.equals(serviceName)) {
|
||||||
|
|
Loading…
Reference in New Issue