Android Open Source - imslpdroid Instrumentation Activity






From Project

Back to project page imslpdroid.

License

The source code is released under:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, includin...

If you think the Android project imslpdroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.imslpdroid;
/*  w w  w  .  j  a  v a  2  s.c  o m*/
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;

import com.imslpdroid.gui.StorableRestrictableListView;

public class InstrumentationActivity extends StorableRestrictableListView {

  private String baseUrl = "http://imslp.org/wiki/IMSLP:View_Genres";
  
  @Override
  public List<String> downloadList(Handler handler, AtomicBoolean stopFlag) throws IOException {
    String url = baseUrl;
    List<String> res = new LinkedList<String>();
    Document doc = Jsoup.connect(url).get();
    Element tables = doc.getElementsByTag("table").get(5);
    if (tables != null) {
      Elements contents = tables.getElementsByClass("plainlinks");
      for (Element content : contents) 
        res.add(content.text());
    }
    return res;
  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setSortingDisabled(true);
    // click on list item
    ListView lv = (ListView) findViewById(R.id.rlv_listview);
    lv.setOnItemClickListener(new OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        String instrumentation = (String) ((TextView) view).getText();
        Intent newIntent = new Intent();
        Bundle bun = new Bundle();
        bun.putString("composer", instrumentation);
        bun.putString("prevPage", "InstrumentationActivity");
        newIntent.setClass(parent.getContext(), PiecesActivity.class);
        newIntent.putExtras(bun);
        startActivity(newIntent);
      }
    });
  }

  @Override
  public String getBaseUrl() {
    return baseUrl + "instrumentationActivity"; //same url as worktypes
  }
}




Java Source Code List

com.imslpdroid.AboutAppActivity.java
com.imslpdroid.ComposersActivity.java
com.imslpdroid.DownloadedActivity.java
com.imslpdroid.ImslpdroidActivity.java
com.imslpdroid.InstrumentationActivity.java
com.imslpdroid.NationalityActivity.java
com.imslpdroid.PiecesActivity.java
com.imslpdroid.RestrictedComposersActivity.java
com.imslpdroid.ScoreDownloadActivity.java
com.imslpdroid.ScoresActivity.java
com.imslpdroid.TimePeriodActivity.java
com.imslpdroid.WorkTypesActivity.java
com.imslpdroid.data.DataStorageHelper.java
com.imslpdroid.data.DataStorage.java
com.imslpdroid.data.ExternalStorageUnavailableException.java
com.imslpdroid.data.Score.java
com.imslpdroid.gui.IntentUtils.java
com.imslpdroid.gui.RestrictableListView.java
com.imslpdroid.gui.ScoreAdapter.java
com.imslpdroid.gui.StorableRestrictableListView.java