Skip to content

Commit e67bcd7

Browse files
author
Arnav Gupta
committed
set raw source and instapaper viewing as separate options
1 parent 3a434df commit e67bcd7

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

App/src/main/java/in/ac/dtu/subtlenews/MainFragment.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package in.ac.dtu.subtlenews;
22

3+
import android.annotation.SuppressLint;
34
import android.annotation.TargetApi;
45
import android.app.Activity;
56
import android.app.AlertDialog;
@@ -153,6 +154,7 @@ protected void onPostExecute(ArrayList<JSONObject> mArrayList){
153154
ListView mLisView = (ListView) rootView.findViewById(R.id.list_news);
154155
mLisView.setAdapter(new ListViewLoader(mArrayList));
155156
mLisView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
157+
@SuppressLint("NewApi")
156158
@Override
157159
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
158160
try {
@@ -165,7 +167,7 @@ public void onItemClick(AdapterView<?> adapterView, View view, final int i, long
165167
AlertDialog summaryBox = new AlertDialog.Builder(getActivity())
166168
.setCustomTitle(summaryTitle)
167169
.setMessage(fArrayList.get(i).getString(TAG_SUMMARY))
168-
.setPositiveButton("Source", new DialogInterface.OnClickListener() {
170+
.setPositiveButton("Instapaper", new DialogInterface.OnClickListener() {
169171
public void onClick(DialogInterface dialog, int id) {
170172
/* TODO :
171173
USE webview to implement in-app browser instead of this
@@ -180,15 +182,34 @@ public void onClick(DialogInterface dialog, int id) {
180182
startActivity(browserIntent);
181183

182184

185+
}
186+
})
187+
.setNegativeButton("Source", new DialogInterface.OnClickListener() {
188+
public void onClick(DialogInterface dialog, int id) {
189+
/* TODO :
190+
USE webview to implement in-app browser instead of this
191+
*/
192+
String url = "http://www.google.com";
193+
try {
194+
url = fArrayList.get(i).getString(TAG_LINK);
195+
} catch (JSONException e) {
196+
e.printStackTrace();
197+
}
198+
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
199+
startActivity(browserIntent);
200+
201+
183202
}
184203
})
185204
.show();
186205
TextView summaryText = (TextView) summaryBox.findViewById(android.R.id.message);
187206
summaryText.setTextSize(12);
188-
if (android.os.Build.VERSION.SDK_INT > 11) {
189-
// Let Android 3.0 above users select the news text
207+
try {
190208
summaryText.setTextIsSelectable(true);
209+
} catch ( Exception e ) {
210+
Log.d (TAG, "text could not be set selectable. possible below android v3.0");
191211
}
212+
192213
} catch (JSONException e) {
193214
e.printStackTrace();
194215
}

0 commit comments

Comments
 (0)