Renamed the callback handler.

This commit is contained in:
Sadique Ali 2013-07-20 15:03:33 -07:00
parent 5b230f5b6a
commit bac9149865
3 changed files with 5 additions and 8 deletions

View File

@ -30,7 +30,7 @@ public class MainActivity extends Activity {
String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
Log.d("Share With Title", "Received shared text: " + sharedText); Log.d("Share With Title", "Received shared text: " + sharedText);
new TitleRetriever(sharedText).retrieve(new TitleViewUpdater() { new TitleRetriever(sharedText).retrieve(new TitleGrabCallback() {
@Override @Override
public void update(String title) { public void update(String title) {
textView.setText(title); textView.setText(title);

View File

@ -3,7 +3,7 @@ package in.sdqali.sharewithtitle;
/** /**
* Created by sdqali on 7/20/13. * Created by sdqali on 7/20/13.
*/ */
public interface TitleViewUpdater { public interface TitleGrabCallback {
public void update(String title); public void update(String title);
public void showProgress(); public void showProgress();
public void finish(); public void finish();

View File

@ -1,11 +1,8 @@
package in.sdqali.sharewithtitle; package in.sdqali.sharewithtitle;
import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import android.webkit.URLUtil; import android.webkit.URLUtil;
import android.widget.TextView;
import android.widget.Toast;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -20,7 +17,7 @@ public class TitleRetriever {
this.urlText = url; this.urlText = url;
} }
public void retrieve(TitleViewUpdater viewUpdater) { public void retrieve(TitleGrabCallback viewUpdater) {
if(isValidUrl(urlText)) { if(isValidUrl(urlText)) {
new DownloadTaskNew(viewUpdater).execute(urlText); new DownloadTaskNew(viewUpdater).execute(urlText);
} else { } else {
@ -33,10 +30,10 @@ public class TitleRetriever {
} }
private class DownloadTaskNew extends AsyncTask<String, Void, String> { private class DownloadTaskNew extends AsyncTask<String, Void, String> {
private TitleViewUpdater viewUpdater; private TitleGrabCallback viewUpdater;
private final PageDownloader pageDownloader = new PageDownloader(); private final PageDownloader pageDownloader = new PageDownloader();
public DownloadTaskNew(TitleViewUpdater viewUpdater) { public DownloadTaskNew(TitleGrabCallback viewUpdater) {
this.viewUpdater = viewUpdater; this.viewUpdater = viewUpdater;
} }