store sid and apilevel in GlobalState
This commit is contained in:
parent
41630980df
commit
4faeb17461
@ -107,7 +107,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
protected void initMenu() {
|
protected void initMenu() {
|
||||||
super.initMenu();
|
super.initMenu();
|
||||||
|
|
||||||
if (m_menu != null && m_sessionId != null) {
|
if (m_menu != null && getSessionId() != null) {
|
||||||
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
Fragment ff = getSupportFragmentManager().findFragmentByTag(FRAG_FEEDS);
|
||||||
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
Fragment cf = getSupportFragmentManager().findFragmentByTag(FRAG_CATS);
|
||||||
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
ArticlePager af = (ArticlePager) getSupportFragmentManager().findFragmentByTag(FRAG_ARTICLE);
|
||||||
@ -143,8 +143,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
if (isSmallScreen()) {
|
if (isSmallScreen()) {
|
||||||
|
|
||||||
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
|
||||||
intent.putExtra("apiLevel", m_apiLevel);
|
|
||||||
intent.putExtra("feed", feed);
|
intent.putExtra("feed", feed);
|
||||||
|
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
@ -177,8 +175,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
if (isSmallScreen()) {
|
if (isSmallScreen()) {
|
||||||
|
|
||||||
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
|
||||||
intent.putExtra("apiLevel", m_apiLevel);
|
|
||||||
intent.putExtra("category", cat);
|
intent.putExtra("category", cat);
|
||||||
|
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
@ -256,9 +252,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
if (isSmallScreen()) {
|
if (isSmallScreen()) {
|
||||||
|
|
||||||
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
Intent intent = new Intent(FeedsActivity.this, FeedsActivity.class);
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
|
||||||
intent.putExtra("apiLevel", m_apiLevel);
|
|
||||||
|
|
||||||
intent.putExtra("feedTitle", hf.getFeed().title);
|
intent.putExtra("feedTitle", hf.getFeed().title);
|
||||||
intent.putExtra("feed", hf.getFeed());
|
intent.putExtra("feed", hf.getFeed());
|
||||||
intent.putExtra("article", article);
|
intent.putExtra("article", article);
|
||||||
@ -269,9 +262,6 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
Intent intent = new Intent(FeedsActivity.this, HeadlinesActivity.class);
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
|
||||||
intent.putExtra("apiLevel", m_apiLevel);
|
|
||||||
|
|
||||||
intent.putExtra("feed", hf.getFeed());
|
intent.putExtra("feed", hf.getFeed());
|
||||||
intent.putExtra("article", article);
|
intent.putExtra("article", article);
|
||||||
intent.putExtra("searchQuery", hf.getSearchQuery());
|
intent.putExtra("searchQuery", hf.getSearchQuery());
|
||||||
|
@ -15,6 +15,8 @@ public class GlobalState extends Application {
|
|||||||
public int m_selectedArticleId;
|
public int m_selectedArticleId;
|
||||||
public boolean m_unreadOnly = true;
|
public boolean m_unreadOnly = true;
|
||||||
public boolean m_unreadArticlesOnly = true;
|
public boolean m_unreadArticlesOnly = true;
|
||||||
|
public String m_sessionId;
|
||||||
|
public int m_apiLevel;
|
||||||
|
|
||||||
public static GlobalState getInstance(){
|
public static GlobalState getInstance(){
|
||||||
return m_singleton;
|
return m_singleton;
|
||||||
|
@ -108,7 +108,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
|||||||
protected void initMenu() {
|
protected void initMenu() {
|
||||||
super.initMenu();
|
super.initMenu();
|
||||||
|
|
||||||
if (m_menu != null && m_sessionId != null) {
|
if (m_menu != null && getSessionId() != null) {
|
||||||
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
||||||
|
|
||||||
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentByTag(FRAG_HEADLINES);
|
||||||
|
@ -45,9 +45,7 @@ import com.google.gson.reflect.TypeToken;
|
|||||||
public class OnlineActivity extends CommonActivity {
|
public class OnlineActivity extends CommonActivity {
|
||||||
private final String TAG = this.getClass().getSimpleName();
|
private final String TAG = this.getClass().getSimpleName();
|
||||||
|
|
||||||
protected String m_sessionId;
|
|
||||||
protected SharedPreferences m_prefs;
|
protected SharedPreferences m_prefs;
|
||||||
protected int m_apiLevel = 0;
|
|
||||||
protected Menu m_menu;
|
protected Menu m_menu;
|
||||||
|
|
||||||
protected int m_offlineModeStatus = 0;
|
protected int m_offlineModeStatus = 0;
|
||||||
@ -112,7 +110,15 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected String getSessionId() {
|
||||||
|
return GlobalState.getInstance().m_sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSessionId(String sessionId) {
|
||||||
|
GlobalState.getInstance().m_sessionId = sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
m_prefs = PreferenceManager
|
m_prefs = PreferenceManager
|
||||||
@ -144,25 +150,17 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
switchOfflineSuccess();
|
switchOfflineSuccess();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (getIntent().getExtras() != null) {
|
/* if (getIntent().getExtras() != null) {
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
|
} */
|
||||||
m_sessionId = i.getStringExtra("sessionId");
|
|
||||||
m_apiLevel = i.getIntExtra("apiLevel", -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
m_sessionId = savedInstanceState.getString("sessionId");
|
|
||||||
m_apiLevel = savedInstanceState.getInt("apiLevel");
|
|
||||||
m_offlineModeStatus = savedInstanceState.getInt("offlineModeStatus");
|
m_offlineModeStatus = savedInstanceState.getInt("offlineModeStatus");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCompatMode()) {
|
if (!isCompatMode()) {
|
||||||
m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
|
m_headlinesActionModeCallback = new HeadlinesActionModeCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "m_sessionId=" + m_sessionId);
|
|
||||||
Log.d(TAG, "m_apiLevel=" + m_apiLevel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +212,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int which) {
|
int which) {
|
||||||
|
|
||||||
if (m_sessionId != null) {
|
if (getSessionId() != null) {
|
||||||
Log.d(TAG, "offline: starting");
|
Log.d(TAG, "offline: starting");
|
||||||
|
|
||||||
m_offlineModeStatus = 1;
|
m_offlineModeStatus = 1;
|
||||||
@ -222,7 +220,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
OnlineActivity.this,
|
OnlineActivity.this,
|
||||||
OfflineDownloadService.class);
|
OfflineDownloadService.class);
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
intent.putExtra("sessionId", getSessionId());
|
||||||
|
|
||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
@ -297,7 +295,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
OnlineActivity.this,
|
OnlineActivity.this,
|
||||||
OfflineUploadService.class);
|
OfflineUploadService.class);
|
||||||
|
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
intent.putExtra("sessionId", getSessionId());
|
||||||
|
|
||||||
startService(intent);
|
startService(intent);
|
||||||
}
|
}
|
||||||
@ -310,7 +308,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int which) {
|
int which) {
|
||||||
|
|
||||||
if (m_sessionId != null) {
|
if (getSessionId() != null) {
|
||||||
Log.d(TAG, "offline: stopping");
|
Log.d(TAG, "offline: stopping");
|
||||||
|
|
||||||
m_offlineModeStatus = 0;
|
m_offlineModeStatus = 0;
|
||||||
@ -344,8 +342,6 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
public void restart() {
|
public void restart() {
|
||||||
Intent refresh = new Intent(OnlineActivity.this, OnlineActivity.class);
|
Intent refresh = new Intent(OnlineActivity.this, OnlineActivity.class);
|
||||||
refresh.putExtra("sessionId", m_sessionId);
|
|
||||||
refresh.putExtra("apiLevel", m_apiLevel);
|
|
||||||
startActivity(refresh);
|
startActivity(refresh);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -418,8 +414,6 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
initMenu();
|
initMenu();
|
||||||
|
|
||||||
Intent intent = new Intent(OnlineActivity.this, FeedsActivity.class);
|
Intent intent = new Intent(OnlineActivity.this, FeedsActivity.class);
|
||||||
intent.putExtra("sessionId", m_sessionId);
|
|
||||||
intent.putExtra("apiLevel", m_apiLevel);
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
@ -513,7 +507,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", articleIds);
|
put("article_ids", articleIds);
|
||||||
put("mode", "0");
|
put("mode", "0");
|
||||||
@ -733,7 +727,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "setArticleLabel");
|
put("op", "setArticleLabel");
|
||||||
put("label_id", String.valueOf(labelId));
|
put("label_id", String.valueOf(labelId));
|
||||||
put("article_ids", String.valueOf(articleId));
|
put("article_ids", String.valueOf(articleId));
|
||||||
@ -763,7 +757,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "getLabels");
|
put("op", "getLabels");
|
||||||
put("article_id", String.valueOf(articleId));
|
put("article_id", String.valueOf(articleId));
|
||||||
}
|
}
|
||||||
@ -773,7 +767,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void logout() {
|
protected void logout() {
|
||||||
m_sessionId = null;
|
setSessionId(null);
|
||||||
|
|
||||||
findViewById(R.id.loading_container).setVisibility(View.VISIBLE);
|
findViewById(R.id.loading_container).setVisibility(View.VISIBLE);
|
||||||
setLoadingStatus(R.string.login_ready, false);
|
setLoadingStatus(R.string.login_ready, false);
|
||||||
@ -782,7 +776,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void loginFailure() {
|
protected void loginFailure() {
|
||||||
m_sessionId = null;
|
setSessionId(null);
|
||||||
initMenu();
|
initMenu();
|
||||||
|
|
||||||
if (hasOfflineData()) {
|
if (hasOfflineData()) {
|
||||||
@ -814,8 +808,6 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
public void onSaveInstanceState(Bundle out) {
|
public void onSaveInstanceState(Bundle out) {
|
||||||
super.onSaveInstanceState(out);
|
super.onSaveInstanceState(out);
|
||||||
|
|
||||||
out.putString("sessionId", m_sessionId);
|
|
||||||
out.putInt("apiLevel", m_apiLevel);
|
|
||||||
out.putInt("offlineModeStatus", m_offlineModeStatus);
|
out.putInt("offlineModeStatus", m_offlineModeStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,7 +822,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
registerReceiver(m_broadcastReceiver, filter);
|
registerReceiver(m_broadcastReceiver, filter);
|
||||||
|
|
||||||
if (m_sessionId == null) {
|
if (getSessionId() == null) {
|
||||||
login();
|
login();
|
||||||
} else {
|
} else {
|
||||||
loginSuccess();
|
loginSuccess();
|
||||||
@ -853,12 +845,12 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getSessionId() {
|
protected int getApiLevel() {
|
||||||
return m_sessionId;
|
return GlobalState.getInstance().m_apiLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getApiLevel() {
|
protected void setApiLevel(int apiLevel) {
|
||||||
return m_apiLevel;
|
GlobalState.getInstance().m_apiLevel = apiLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "serial" })
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
@ -867,7 +859,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", String.valueOf(article.id));
|
put("article_ids", String.valueOf(article.id));
|
||||||
put("mode", article.unread ? "1" : "0");
|
put("mode", article.unread ? "1" : "0");
|
||||||
@ -888,7 +880,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", String.valueOf(article.id));
|
put("article_ids", String.valueOf(article.id));
|
||||||
put("mode", article.marked ? "1" : "0");
|
put("mode", article.marked ? "1" : "0");
|
||||||
@ -910,7 +902,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", String.valueOf(article.id));
|
put("article_ids", String.valueOf(article.id));
|
||||||
put("mode", article.published ? "1" : "0");
|
put("mode", article.published ? "1" : "0");
|
||||||
@ -931,7 +923,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", String.valueOf(article.id));
|
put("article_ids", String.valueOf(article.id));
|
||||||
put("mode", "1");
|
put("mode", "1");
|
||||||
@ -995,7 +987,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "catchupFeed");
|
put("op", "catchupFeed");
|
||||||
put("feed_id", String.valueOf(feed.id));
|
put("feed_id", String.valueOf(feed.id));
|
||||||
if (feed.is_cat)
|
if (feed.is_cat)
|
||||||
@ -1013,7 +1005,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", articlesToIdString(articles));
|
put("article_ids", articlesToIdString(articles));
|
||||||
put("mode", "2");
|
put("mode", "2");
|
||||||
@ -1031,7 +1023,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", articlesToIdString(articles));
|
put("article_ids", articlesToIdString(articles));
|
||||||
put("mode", "2");
|
put("mode", "2");
|
||||||
@ -1050,7 +1042,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "updateArticle");
|
put("op", "updateArticle");
|
||||||
put("article_ids", articlesToIdString(articles));
|
put("article_ids", articlesToIdString(articles));
|
||||||
put("mode", "2");
|
put("mode", "2");
|
||||||
@ -1064,7 +1056,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
protected void initMenu() {
|
protected void initMenu() {
|
||||||
if (m_menu != null) {
|
if (m_menu != null) {
|
||||||
if (m_sessionId != null) {
|
if (getSessionId() != null) {
|
||||||
m_menu.setGroupVisible(R.id.menu_group_logged_in, true);
|
m_menu.setGroupVisible(R.id.menu_group_logged_in, true);
|
||||||
m_menu.setGroupVisible(R.id.menu_group_logged_out, false);
|
m_menu.setGroupVisible(R.id.menu_group_logged_out, false);
|
||||||
} else {
|
} else {
|
||||||
@ -1077,11 +1069,11 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
m_menu.setGroupVisible(R.id.menu_group_article, false);
|
m_menu.setGroupVisible(R.id.menu_group_article, false);
|
||||||
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
m_menu.setGroupVisible(R.id.menu_group_feeds, false);
|
||||||
|
|
||||||
m_menu.findItem(R.id.set_labels).setEnabled(m_apiLevel >= 1);
|
m_menu.findItem(R.id.set_labels).setEnabled(getApiLevel() >= 1);
|
||||||
m_menu.findItem(R.id.article_set_note).setEnabled(m_apiLevel >= 1);
|
m_menu.findItem(R.id.article_set_note).setEnabled(getApiLevel() >= 1);
|
||||||
|
|
||||||
MenuItem search = m_menu.findItem(R.id.search);
|
MenuItem search = m_menu.findItem(R.id.search);
|
||||||
search.setEnabled(m_apiLevel >= 2);
|
search.setEnabled(getApiLevel() >= 2);
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
if (android.os.Build.VERSION.SDK_INT >= 14) {
|
||||||
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
|
ShareActionProvider shareProvider = (ShareActionProvider) m_menu.findItem(R.id.share_article).getActionProvider();
|
||||||
@ -1182,18 +1174,17 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
try {
|
try {
|
||||||
JsonObject content = result.getAsJsonObject();
|
JsonObject content = result.getAsJsonObject();
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
m_sessionId = content.get("session_id").getAsString();
|
setSessionId(content.get("session_id").getAsString());
|
||||||
|
|
||||||
Log.d(TAG, "Authenticated!");
|
Log.d(TAG, "Authenticated!");
|
||||||
|
|
||||||
ApiRequest req = new ApiRequest(m_context) {
|
ApiRequest req = new ApiRequest(m_context) {
|
||||||
protected void onPostExecute(JsonElement result) {
|
protected void onPostExecute(JsonElement result) {
|
||||||
m_apiLevel = 0;
|
setApiLevel(0);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
try {
|
try {
|
||||||
m_apiLevel = result.getAsJsonObject()
|
setApiLevel(result.getAsJsonObject().get("level").getAsInt());
|
||||||
.get("level").getAsInt();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -1203,7 +1194,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "Received API level: " + m_apiLevel);
|
Log.d(TAG, "Received API level: " + getApiLevel());
|
||||||
|
|
||||||
loginSuccess();
|
loginSuccess();
|
||||||
return;
|
return;
|
||||||
@ -1213,7 +1204,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
{
|
{
|
||||||
put("sid", m_sessionId);
|
put("sid", getSessionId());
|
||||||
put("op", "getApiLevel");
|
put("op", "getApiLevel");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1230,7 +1221,7 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sessionId = null;
|
setSessionId(null);
|
||||||
setLoadingStatus(getErrorMessage(), false);
|
setLoadingStatus(getErrorMessage(), false);
|
||||||
|
|
||||||
loginFailure();
|
loginFailure();
|
||||||
|
Loading…
Reference in New Issue
Block a user