сОБСТВЕННО САМА ОШИБКА :
Error:(55, 30) error: non-static method execute(Params...) cannot be referenced from a static context
where Params,Progress,Result are type-variables:
Params extends Object declared in class AsyncTask
Progress extends Object declared in class AsyncTask
Result extends Object declared in class AsyncTask
package com.example.kiruha_21.parse1;
import android.os.AsyncTask;
import android.provider.DocumentsContract;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.select.Elements;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
public class MainActivity extends AppCompatActivity {
private ListView ListView;
private TextView TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView = (ListView) findViewById(R.id.ListView);
TextView = (TextView) findViewById(R.id.TextView);
ParseTitle parseTitle = new ParseTitle();
parseTitle.execute();
try {
final HashMap<String,String> hashMap = parseTitle.get();
final ArrayList<String> arrayList = new ArrayList<>();
for (Map.Entry entry : hashMap.entrySet()){
arrayList.add(entry.getKey().toString());
}
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(MainActivity.this
,android.R.layout.simple_list_item_1,arrayList);
ListView.setAdapter(arrayAdapter);
ListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ParseText parseText = new ParseText();
ParseText.execute(hashMap.get(arrayList.get(position)));
try {
ListView.setVisibility(View.GONE);
TextView.setText(parseText.get());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
@Override
public void onBackPressed() {
ListView.setVisibility(View.VISIBLE);
TextView.setVisibility(View.GONE);
}
static class ParseText extends AsyncTask<String,Void,String>{
@Override
protected String doInBackground(String... params) {
String str = " ";
try {
org.jsoup.nodes.Document document = Jsoup.connect(params[0]).get();
org.jsoup.nodes.Element element = document.select(".itemFullText").first();
str = element.text();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
class ParseTitle extends AsyncTask<Void,Void,HashMap<String,String>>{
@Override
protected HashMap<String, String> doInBackground(Void... voids) {
HashMap<String,String> hashMap = new HashMap<>();
try {
org.jsoup.nodes.Document document = Jsoup.connect("http://www.ndu.edu.ua/index.php/ua/vsi-novuni").get();
Elements elements = document.select(".catItemTitle");
for(org.jsoup.nodes.Element element : elements){
org.jsoup.nodes.Element element1 = element.select("a[href]").first();
hashMap.put(element.text(),element1.attr("abs:href"));
}
} catch (IOException e) {
e.printStackTrace();
}
return hashMap;
}
}
}