misc fixes

This commit is contained in:
Andrew Dolgov 2011-09-10 12:03:32 +04:00
parent afc8996fff
commit 09fed5025f
6 changed files with 45 additions and 20 deletions

View File

@ -1,8 +1,8 @@
<LinearLayout android:padding="6dip" android:id="@+id/article_fragment" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical">
<LinearLayout android:layout_margin="12dip" android:padding="6dip" android:background="#e0e0e0" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/article_header">
<TextView android:layout_weight="1" android:textAppearance="?android:attr/textAppearanceLarge" android:text="TextView" android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/title"></TextView>
<LinearLayout android:id="@+id/article_fragment" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical">
<LinearLayout android:layout_gravity="center_vertical" android:padding="6dip" android:background="#e0e0e0" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/article_header">
<TextView android:layout_weight="1" android:text="TextView" android:layout_height="wrap_content" android:textColor="#909090" android:layout_width="match_parent" android:id="@+id/title"></TextView>
<Button android:text="Close" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/close_button"></Button>
</LinearLayout>
<WebView android:layout_width="match_parent" android:id="@+id/content" android:layout_height="match_parent"></WebView>
<WebView android:padding="3dip" android:layout_width="match_parent" android:id="@+id/content" android:layout_height="match_parent"></WebView>
</LinearLayout>

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:padding="3dip" android:id="@+id/headlines_row" android:orientation="horizontal">
android:padding="3dip" android:id="@+id/headlines_row" android:orientation="horizontal" android:layout_height="wrap_content">
<CheckBox android:focusable="false"
android:paddingLeft="6dip" android:paddingRight="6dip" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/selected"></CheckBox>

View File

@ -1,8 +1,15 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_height="fill_parent" android:id="@+id/main_flipper">
<LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal">
<FrameLayout android:layout_gravity="center_vertical" android:id="@+id/sync_splash" android:layout_width="match_parent" android:layout_height="match_parent">
<LinearLayout android:gravity="center" android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent">
<ProgressBar android:id="@+id/loading_progress" android:layout_height="wrap_content" android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge"></ProgressBar>
<TextView android:textAppearance="?android:attr/textAppearanceLarge" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/loading_message" android:text="@string/loading_message"></TextView>
</LinearLayout>
</FrameLayout>
<LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:id="@+id/main">
<LinearLayout android:layout_weight="1.5" android:layout_height="match_parent" android:id="@+id/linearLayout4" android:layout_width="match_parent">
@ -25,11 +32,11 @@
<ImageView android:paddingRight="2dip" android:layout_height="match_parent" android:background="?feedlistDivider" android:layout_width="wrap_content" android:paddingLeft="2dip"></ImageView>
<LinearLayout android:layout_weight="1" android:visibility="gone" android:layout_width="match_parent" android:background="#f0f0ff" android:id="@+id/article_container" android:layout_height="match_parent"></LinearLayout>
<LinearLayout android:layout_weight="1" android:visibility="gone" android:layout_width="match_parent" android:id="@+id/article_container" android:layout_height="match_parent"></LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</ViewFlipper>

View File

@ -28,4 +28,5 @@
<string name="online">Online</string>
<string name="synchronizing">Synchronizing...</string>
<string name="no_headlines">No articles found.</string>
<string name="loading_message">Loading, please wait...</string>
</resources>

View File

@ -48,7 +48,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener {
DatabaseHelper helper = new DatabaseHelper(getActivity());
m_db = helper.getReadableDatabase();
m_cursor = m_db.query("feeds_unread", null, "unread > 0", null, null, null, "title");
m_cursor = m_db.query("feeds_unread", null, null, null, null, null, "unread DESC, title");
m_adapter = new FeedsListAdapter(getActivity(), R.layout.feeds_row, m_cursor,
new String[] { "title", "unread" }, new int[] { R.id.title, R.id.unread_counter }, 0);

View File

@ -23,8 +23,8 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ViewFlipper;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
@ -37,14 +37,14 @@ public class MainActivity extends Activity {
private final static int UPDATE_SEQUENTIAL = 2;
private final static int UPDATE_OFFLINE = 3;
private final static int INITIAL_OFFSET_MAX = 100;
private final static int OFFSET_MAX = 100;
private SharedPreferences m_prefs;
private String m_themeName = "";
private boolean m_feedsOpened = false;
protected String m_sessionId;
protected int m_offset = 0;
protected int m_limit = 25;
protected int m_limit = 30;
protected int m_maxId = 0;
protected int m_updateMode = UPDATE_INITIAL;
@ -79,7 +79,7 @@ public class MainActivity extends Activity {
private class FeedsTask extends TimerTask {
@Override
public void run() {
downloadFeeds();
downloadFeeds();
}
};
@ -144,7 +144,7 @@ public class MainActivity extends Activity {
m_feedsOpened = true;
}
scheduleNextUpdate();
//scheduleNextUpdate();
}
@Override
@ -174,6 +174,12 @@ public class MainActivity extends Activity {
public void onDestroy() {
super.onDestroy();
m_feedsTask.cancel();
m_articlesTask.cancel();
m_feedsTimer.cancel();
m_feedsTimer = null;
m_articlesTimer.cancel();
m_articlesTimer = null;
}
@ -343,7 +349,7 @@ public class MainActivity extends Activity {
Log.d(TAG, articlesFound + " articles processed");
if (m_updateMode == UPDATE_INITIAL && articlesFound == m_limit && m_offset < INITIAL_OFFSET_MAX) {
if (articlesFound == m_limit && m_offset < OFFSET_MAX) {
m_offset += m_limit;
@ -363,6 +369,17 @@ public class MainActivity extends Activity {
}
}
runOnUiThread(new Runnable() {
@Override
public void run() {
ViewFlipper vf = (ViewFlipper) findViewById(R.id.main_flipper);
if (vf != null && vf.getDisplayedChild() == 0) {
vf.showNext();
}
}
});
scheduleNextUpdate();
} catch (Exception e) {
@ -386,7 +403,7 @@ public class MainActivity extends Activity {
put("sid", m_sessionId);
put("op", "getFeeds");
put("cat_id", "-3");
put("unread_only", "0");
put("unread_only", "1");
}
});
@ -454,10 +471,11 @@ public class MainActivity extends Activity {
if (frag != null) {
frag.updateListView();
}
}
}
});
scheduleNextUpdate();
} catch (Exception e) {
e.printStackTrace();