work around against activity always asking about continue/stop sync;
misc fixes
This commit is contained in:
parent
21126446c2
commit
e9fa47175c
@ -58,21 +58,21 @@
|
|||||||
android:id="@+id/tags"
|
android:id="@+id/tags"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="0.7"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:text="{TAGS}"
|
android:text="{TAGS}"
|
||||||
android:textSize="10sp" />
|
android:textSize="13sp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/date"
|
android:id="@+id/date"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="0.2"
|
||||||
android:gravity="right"
|
android:gravity="right"
|
||||||
android:text="{DATE}"
|
android:text="{DATE}"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textSize="10sp" />
|
android:textSize="13sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -135,4 +135,5 @@
|
|||||||
<string name="justify_article_text">Justify article text</string>
|
<string name="justify_article_text">Justify article text</string>
|
||||||
<string name="dialog_offline_sync_in_progress">Offline sync in progress</string>
|
<string name="dialog_offline_sync_in_progress">Offline sync in progress</string>
|
||||||
<string name="dialog_offline_sync_stop">Stop syncing</string>
|
<string name="dialog_offline_sync_stop">Stop syncing</string>
|
||||||
|
<string name="dialog_offline_sync_continue">Continue</string>
|
||||||
</resources>
|
</resources>
|
@ -10,7 +10,7 @@ public class DummyFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.article_fragment, container, false);
|
View view = inflater.inflate(R.layout.dummy_fragment, container, false);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,8 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getActivity().setProgressBarIndeterminateVisibility(showProgress);
|
if (getActivity() != null)
|
||||||
|
getActivity().setProgressBarIndeterminateVisibility(showProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -251,7 +251,8 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getActivity().setProgressBarIndeterminateVisibility(showProgress);
|
if (getActivity() != null)
|
||||||
|
getActivity().setProgressBarIndeterminateVisibility(showProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "serial" })
|
@SuppressWarnings({ "unchecked", "serial" })
|
||||||
|
@ -256,7 +256,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getActivity().setProgressBarIndeterminateVisibility(showProgress);
|
if (getActivity() != null)
|
||||||
|
getActivity().setProgressBarIndeterminateVisibility(showProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class HeadlinesRequest extends ApiRequest {
|
private class HeadlinesRequest extends ApiRequest {
|
||||||
|
@ -138,10 +138,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
} else if (intent.getAction().equals(OfflineUploadService.INTENT_ACTION_SUCCESS)) {
|
} else if (intent.getAction().equals(OfflineUploadService.INTENT_ACTION_SUCCESS)) {
|
||||||
//Log.d(TAG, "offline upload service reports success");
|
//Log.d(TAG, "offline upload service reports success");
|
||||||
|
|
||||||
if (!m_enableCats || m_activeCategory != null)
|
refresh();
|
||||||
refreshFeeds();
|
|
||||||
else
|
|
||||||
refreshCategories();
|
|
||||||
|
|
||||||
Toast toast = Toast.makeText(MainActivity.this, R.string.offline_sync_success, Toast.LENGTH_SHORT);
|
Toast toast = Toast.makeText(MainActivity.this, R.string.offline_sync_success, Toast.LENGTH_SHORT);
|
||||||
toast.show();
|
toast.show();
|
||||||
@ -264,10 +261,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
|
|
||||||
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
ApiRequest req = new ApiRequest(getApplicationContext()) {
|
||||||
protected void onPostExecute(JsonElement result) {
|
protected void onPostExecute(JsonElement result) {
|
||||||
if (!m_enableCats || m_activeCategory != null)
|
refresh();
|
||||||
refreshFeeds();
|
|
||||||
else
|
|
||||||
refreshCategories();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -320,6 +314,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
};
|
};
|
||||||
|
|
||||||
req.execute(map);
|
req.execute(map);
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@ -355,10 +350,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!m_enableCats || m_activeCategory != null)
|
refresh();
|
||||||
refreshFeeds();
|
|
||||||
else
|
|
||||||
refreshCategories();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -367,16 +359,24 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void refreshFeeds() {
|
private synchronized void refresh() {
|
||||||
if (m_sessionId != null) {
|
if (m_sessionId != null) {
|
||||||
FeedsFragment frag = (FeedsFragment) getSupportFragmentManager()
|
FeedsFragment ff = (FeedsFragment) getSupportFragmentManager()
|
||||||
.findFragmentByTag(FRAG_FEEDS);
|
.findFragmentByTag(FRAG_FEEDS);
|
||||||
|
|
||||||
Log.d(TAG, "Refreshing feeds...");
|
if (ff != null) {
|
||||||
|
Log.d(TAG, "Refreshing feeds...");
|
||||||
if (frag != null) {
|
ff.refresh(true);
|
||||||
frag.refresh(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FeedCategoriesFragment cf = (FeedCategoriesFragment) getSupportFragmentManager()
|
||||||
|
.findFragmentByTag(FRAG_CATS);
|
||||||
|
|
||||||
|
if (cf != null) {
|
||||||
|
Log.d(TAG, "Refreshing categories...");
|
||||||
|
cf.refresh(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,26 +393,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
|
|
||||||
private synchronized void refreshCategories() {
|
|
||||||
if (m_sessionId != null) {
|
|
||||||
FeedCategoriesFragment frag = (FeedCategoriesFragment) getSupportFragmentManager()
|
|
||||||
.findFragmentByTag(FRAG_CATS);
|
|
||||||
|
|
||||||
Log.d(TAG, "Refreshing categories...");
|
|
||||||
|
|
||||||
if (frag != null) {
|
|
||||||
frag.refresh(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setUnreadOnly(boolean unread) {
|
private void setUnreadOnly(boolean unread) {
|
||||||
m_unreadOnly = unread;
|
m_unreadOnly = unread;
|
||||||
|
refresh();
|
||||||
if (!m_enableCats || m_activeCategory != null)
|
|
||||||
refreshFeeds();
|
|
||||||
else
|
|
||||||
refreshCategories();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -621,7 +604,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
private void cancelOfflineSync() {
|
private void cancelOfflineSync() {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
AlertDialog.Builder builder = new AlertDialog.Builder(this)
|
||||||
.setMessage(R.string.dialog_offline_sync_in_progress)
|
.setMessage(R.string.dialog_offline_sync_in_progress)
|
||||||
.setPositiveButton(R.string.dialog_offline_sync_stop,
|
.setNegativeButton(R.string.dialog_offline_sync_stop,
|
||||||
new Dialog.OnClickListener() {
|
new Dialog.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int which) {
|
int which) {
|
||||||
@ -636,14 +619,27 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
OfflineDownloadService.class);
|
OfflineDownloadService.class);
|
||||||
|
|
||||||
stopService(intent);
|
stopService(intent);
|
||||||
|
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
Intent refresh = new Intent(MainActivity.this, MainActivity.class);
|
||||||
|
refresh.putExtra("sessionId", m_sessionId);
|
||||||
|
startActivity(refresh);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.dialog_cancel,
|
.setPositiveButton(R.string.dialog_offline_sync_continue,
|
||||||
new Dialog.OnClickListener() {
|
new Dialog.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog,
|
public void onClick(DialogInterface dialog,
|
||||||
int which) {
|
int which) {
|
||||||
//
|
|
||||||
|
dialog.dismiss();
|
||||||
|
|
||||||
|
Intent refresh = new Intent(MainActivity.this, MainActivity.class);
|
||||||
|
refresh.putExtra("sessionId", m_sessionId);
|
||||||
|
startActivity(refresh);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -766,7 +762,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
ft.commit();
|
ft.commit();
|
||||||
|
|
||||||
initMainMenu();
|
initMainMenu();
|
||||||
refreshCategories();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deselectAllArticles() {
|
private void deselectAllArticles() {
|
||||||
@ -810,13 +806,17 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
} else {
|
} else {
|
||||||
if (m_selectedArticle != null) {
|
if (m_selectedArticle != null) {
|
||||||
closeArticle();
|
closeArticle();
|
||||||
|
refresh();
|
||||||
|
} else if (m_activeFeed != null) {
|
||||||
|
m_activeFeed = null;
|
||||||
|
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.replace(R.id.headlines_fragment, new DummyFragment(), "");
|
||||||
|
ft.commit();
|
||||||
|
|
||||||
|
initMainMenu();
|
||||||
} else if (m_activeCategory != null) {
|
} else if (m_activeCategory != null) {
|
||||||
closeCategory();
|
closeCategory();
|
||||||
/* } else if (m_activeFeed != null) {
|
|
||||||
m_activeFeed = null;
|
|
||||||
findViewById(R.id.headlines_fragment).setVisibility(View.GONE);
|
|
||||||
initMainMenu(); */
|
|
||||||
|
|
||||||
} else if (allowQuit) {
|
} else if (allowQuit) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -916,10 +916,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
return true;
|
return true;
|
||||||
case R.id.update_feeds:
|
case R.id.update_feeds:
|
||||||
if (!m_enableCats || m_activeCategory != null)
|
refresh();
|
||||||
refreshFeeds();
|
|
||||||
else
|
|
||||||
refreshCategories();
|
|
||||||
return true;
|
return true;
|
||||||
case R.id.logout:
|
case R.id.logout:
|
||||||
logout();
|
logout();
|
||||||
@ -989,6 +986,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
};
|
};
|
||||||
|
|
||||||
req.execute(map);
|
req.execute(map);
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.share_article:
|
case R.id.share_article:
|
||||||
@ -998,7 +996,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
if (m_selectedArticle != null) {
|
if (m_selectedArticle != null) {
|
||||||
m_selectedArticle.marked = !m_selectedArticle.marked;
|
m_selectedArticle.marked = !m_selectedArticle.marked;
|
||||||
saveArticleMarked(m_selectedArticle);
|
saveArticleMarked(m_selectedArticle);
|
||||||
updateHeadlines();
|
//updateHeadlines();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.selection_select_none:
|
case R.id.selection_select_none:
|
||||||
@ -1015,6 +1013,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
toggleArticlesUnread(selected);
|
toggleArticlesUnread(selected);
|
||||||
hf.notifyUpdated();
|
hf.notifyUpdated();
|
||||||
}
|
}
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.selection_toggle_marked:
|
case R.id.selection_toggle_marked:
|
||||||
@ -1085,16 +1084,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
/*
|
|
||||||
* case R.id.show_all_articles:
|
|
||||||
* setUnreadArticlesOnly(!getUnreadArticlesOnly());
|
|
||||||
*
|
|
||||||
* if (getUnreadArticlesOnly()) {
|
|
||||||
* item.setTitle(R.string.show_all_articles); } else {
|
|
||||||
* item.setTitle(R.string.show_unread_articles); }
|
|
||||||
*
|
|
||||||
* return true;
|
|
||||||
*/
|
|
||||||
case R.id.set_labels:
|
case R.id.set_labels:
|
||||||
if (m_selectedArticle != null) {
|
if (m_selectedArticle != null) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user