-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentActivity.java
More file actions
141 lines (111 loc) · 4.16 KB
/
Copy pathContentActivity.java
File metadata and controls
141 lines (111 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.example.newsreader;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.TextView;
public class ContentActivity extends Activity{
NewsData news = new NewsData(this);
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Bundle bundle = getIntent().getExtras();
//String name = bundle.getString("name");
setContentView(R.layout.activity_content);
Intent intent = getIntent();
/*String textTitle = intent.getStringExtra(MainActivity.EXTRA_MESSAGE1);
TextView Title = (TextView) findViewById(R.id.CTitle);
Title.append(textTitle);
String textTime = intent.getStringExtra(MainActivity.EXTRA_MESSAGE2);
TextView Time = (TextView) findViewById(R.id.CTime);
Time.append(textTime);
String textWebsite = intent.getStringExtra(MainActivity.EXTRA_MESSAGE3);
TextView Website = (TextView) findViewById(R.id.CWebsite);
Website.append(textWebsite);
String textProgram = intent.getStringExtra(MainActivity.EXTRA_MESSAGE4);
TextView Program = (TextView) findViewById(R.id.CProgram);
Program.append(textProgram);*/
String textContent = intent.getStringExtra(MainActivity.EXTRA_MESSAGE5);
//String textURL = intent.getStringExtra(MainActivity.EXTRA_MESSAGE6);
WebView myWebView = (WebView) findViewById(R.id.CContent);
myWebView.loadDataWithBaseURL("www.baidu.com",textContent, "text/html","utf-8", null);
//TextView Content = (TextView) findViewById(R.id.CContent);
//Content.append(textContent);
// Show the Up button in the action bar.
setupActionBar();
}
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.content, menu);
return true;
}
@SuppressLint("NewApi")
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_settings:
Intent preferencesIntent = new Intent(this, SettingsActivity.class);
startActivity(preferencesIntent);
return true;
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// http://developer.android.com/design/patterns/navigation.html#up-vs-back
//
NavUtils.navigateUpFromSameTask(this);
return true;
case R.id.browser:
openInBrowser();
return true;
case R.id.save_news:
readToSelected();
return true;
case R.id.unsave_news:
selectedToRead();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void openInBrowser(){
Intent intent = getIntent();
String entryid = intent.getStringExtra(MainActivity.EXTRA_MESSAGE6);
Uri uri = Uri.parse(entryid);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);
}
public void readToSelected(){
Intent intent = getIntent();
String entryid = intent.getStringExtra(MainActivity.EXTRA_MESSAGE6);
news.changeStatus(entryid, "ReadToSelected");
}
public void selectedToRead(){
Intent intent = getIntent();
String entryid = intent.getStringExtra(MainActivity.EXTRA_MESSAGE6);
news.changeStatus(entryid, "SelectedToRead");
}
}