|
4 | 4 |
|
5 | 5 | import android.annotation.TargetApi; |
6 | 6 | import android.app.Activity; |
| 7 | +import android.content.DialogInterface; |
7 | 8 | import android.content.Intent; |
8 | 9 | import android.os.Build; |
9 | 10 | import android.os.Bundle; |
|
13 | 14 | import android.view.MenuItem; |
14 | 15 | import android.support.v4.app.NavUtils; |
15 | 16 | import android.webkit.WebView; |
| 17 | +import android.widget.Button; |
16 | 18 | import android.widget.FrameLayout; |
17 | 19 | import android.widget.LinearLayout; |
18 | 20 |
|
| 21 | +import org.json.JSONException; |
| 22 | +import org.json.JSONObject; |
| 23 | + |
| 24 | +import java.util.ArrayList; |
| 25 | + |
19 | 26 | /** |
20 | 27 | * An example full-screen activity that shows and hides the system UI (i.e. |
21 | 28 | * status bar and navigation/system bar) with user interaction. |
|
24 | 31 | */ |
25 | 32 | public class InstapaperViewer extends Activity { |
26 | 33 | public String summaryUrl = "http://google.com"; |
| 34 | + public Integer urlId = 0; |
| 35 | + public ArrayList<String> urlList; |
| 36 | + |
27 | 37 |
|
28 | 38 | /** |
29 | 39 | * Whether or not the system UI should be auto-hidden after |
@@ -62,13 +72,18 @@ protected void onCreate(Bundle savedInstanceState) { |
62 | 72 |
|
63 | 73 | Bundle extras = getIntent().getExtras(); |
64 | 74 | if (extras != null) { |
65 | | - summaryUrl = extras.getString("URL"); |
| 75 | + urlId = extras.getInt("URLID"); |
| 76 | + urlList = extras.getStringArrayList("URLList"); |
| 77 | + |
66 | 78 | } |
67 | 79 | final WebView instapaperView = (WebView) findViewById(R.id.instapaper_viewer); |
68 | 80 |
|
69 | 81 | final View controlsView = findViewById(R.id.fullscreen_content_controls); |
70 | 82 | final View contentView = findViewById(R.id.instapaper_viewer); |
71 | 83 |
|
| 84 | + final Button prevButton = (Button) findViewById(R.id.summary_prev_button); |
| 85 | + final Button nextButton = (Button) findViewById(R.id.summary_next_button); |
| 86 | + |
72 | 87 | // Set up an instance of SystemUiHider to control the system UI for |
73 | 88 | // this activity. |
74 | 89 | mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS); |
@@ -135,10 +150,38 @@ public void onClick(View view) { |
135 | 150 | // Upon interacting with UI controls, delay any scheduled hide() |
136 | 151 | // operations to prevent the jarring behavior of controls going away |
137 | 152 | // while interacting with the UI. |
138 | | - findViewById(R.id.summary_back_button).setOnTouchListener(mDelayHideTouchListener); |
139 | | - |
| 153 | + prevButton.setOnTouchListener(mDelayHideTouchListener); |
| 154 | + nextButton.setOnTouchListener(mDelayHideTouchListener); |
140 | 155 |
|
| 156 | + try { |
| 157 | + summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(urlId); |
| 158 | + } catch (Exception e) { |
| 159 | + e.printStackTrace(); |
| 160 | + } |
141 | 161 | instapaperView.loadUrl(summaryUrl); |
| 162 | + prevButton.setOnClickListener(new View.OnClickListener() { |
| 163 | + @Override |
| 164 | + public void onClick(View view) { |
| 165 | + try { |
| 166 | + summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(--urlId); |
| 167 | + } catch (Exception e) { |
| 168 | + e.printStackTrace(); |
| 169 | + } |
| 170 | + instapaperView.loadUrl(summaryUrl); |
| 171 | + } |
| 172 | + }); |
| 173 | + nextButton.setOnClickListener(new View.OnClickListener() { |
| 174 | + @Override |
| 175 | + public void onClick(View view) { |
| 176 | + try { |
| 177 | + summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(++urlId); |
| 178 | + } catch (Exception e) { |
| 179 | + e.printStackTrace(); |
| 180 | + } |
| 181 | + instapaperView.loadUrl(summaryUrl); |
| 182 | + } |
| 183 | + }); |
| 184 | + |
142 | 185 | } |
143 | 186 |
|
144 | 187 | @Override |
|
0 commit comments