use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetTag in project AntennaPod by AntennaPod.
the class TagListFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getListView().setOnItemClickListener((parent, view1, position, id) -> {
GpodnetTag tag = (GpodnetTag) getListAdapter().getItem(position);
((MainActivity) getActivity()).loadChildFragment(TagFragment.newInstance(tag));
});
startLoadTask();
}
use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetTag in project AntennaPod by AntennaPod.
the class TagListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder holder;
GpodnetTag tag = getItem(position);
// Inflate Layout
if (convertView == null) {
holder = new Holder();
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.gpodnet_tag_listitem, parent, false);
holder.title = convertView.findViewById(R.id.txtvTitle);
holder.usage = convertView.findViewById(R.id.txtvUsage);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
holder.title.setText(tag.getTitle());
holder.usage.setText(String.valueOf(tag.getUsage()));
return convertView;
}
use of de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetTag in project AntennaPod by AntennaPod.
the class GpodnetService method getTopTags.
/**
* Returns the [count] most used tags.
*/
public List<GpodnetTag> getTopTags(int count) throws GpodnetServiceException {
URL url;
try {
url = new URI(baseScheme, null, baseHost, basePort, String.format(Locale.US, "/api/2/tags/%d.json", count), null, null).toURL();
} catch (MalformedURLException | URISyntaxException e) {
e.printStackTrace();
throw new GpodnetServiceException(e);
}
Request.Builder request = new Request.Builder().url(url);
String response = executeRequest(request);
try {
JSONArray jsonTagList = new JSONArray(response);
List<GpodnetTag> tagList = new ArrayList<>(jsonTagList.length());
for (int i = 0; i < jsonTagList.length(); i++) {
JSONObject jsonObject = jsonTagList.getJSONObject(i);
String title = jsonObject.getString("title");
String tag = jsonObject.getString("tag");
int usage = jsonObject.getInt("usage");
tagList.add(new GpodnetTag(title, tag, usage));
}
return tagList;
} catch (JSONException e) {
e.printStackTrace();
throw new GpodnetServiceException(e);
}
}
Aggregations