From c55ae41fbdbc82256e622d4be22c28f08221941e Mon Sep 17 00:00:00 2001 From: Jayin Ton Date: Tue, 23 Feb 2016 01:18:01 +0800 Subject: [PATCH] support list --- app/src/main/AndroidManifest.xml | 12 ++- .../io/github/emanual/app/api/EmanualAPI.java | 10 ++- .../app/ui/InterviewFeedsActivity.java | 83 +++++++++++++++++++ .../app/ui/fragment/ExploreFragment.java | 9 +- .../main/res/layout/acty_interview_feeds.xml | 44 ++++++++++ app/src/main/res/layout/fragment_explore.xml | 28 ++++++- app/src/main/res/values-v21/styles.xml | 2 + app/src/main/res/values-w820dp/dimens.xml | 6 ++ app/src/main/res/values/dimens.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 4 + 11 files changed, 190 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/io/github/emanual/app/ui/InterviewFeedsActivity.java create mode 100644 app/src/main/res/layout/acty_interview_feeds.xml create mode 100644 app/src/main/res/values-v21/styles.xml create mode 100644 app/src/main/res/values-w820dp/dimens.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2037dc4..917ff51 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,7 @@ - + @@ -86,6 +85,11 @@ android:value="${UMENG_CHANNEL_VALUE}"/> + + diff --git a/app/src/main/java/io/github/emanual/app/api/EmanualAPI.java b/app/src/main/java/io/github/emanual/app/api/EmanualAPI.java index 0a3be9c..fecc5ba 100644 --- a/app/src/main/java/io/github/emanual/app/api/EmanualAPI.java +++ b/app/src/main/java/io/github/emanual/app/api/EmanualAPI.java @@ -34,10 +34,18 @@ public static void getLangInfo(String lang, AsyncHttpResponseHandler responseHan } /** - * 获取feeds + * 获取Book feeds * @param responseHandler */ public static void getBookFeeds(AsyncHttpResponseHandler responseHandler){ RestClient.get(RestClient.URL_FEEDS,"/feeds-book/feeds/all.min.json", null, responseHandler); } + + /** + * 获取Interview feeds + * @param responseHandler + */ + public static void getInterviewFeeds(AsyncHttpResponseHandler responseHandler){ + RestClient.get(RestClient.URL_FEEDS,"/feeds-interview/feeds/all.min.json", null, responseHandler); + } } diff --git a/app/src/main/java/io/github/emanual/app/ui/InterviewFeedsActivity.java b/app/src/main/java/io/github/emanual/app/ui/InterviewFeedsActivity.java new file mode 100644 index 0000000..637f296 --- /dev/null +++ b/app/src/main/java/io/github/emanual/app/ui/InterviewFeedsActivity.java @@ -0,0 +1,83 @@ +package io.github.emanual.app.ui; + +import android.app.ProgressDialog; +import android.os.Bundle; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; + +import com.loopj.android.http.AsyncHttpResponseHandler; + +import java.util.List; + +import butterknife.Bind; +import cz.msebera.android.httpclient.Header; +import io.github.emanual.app.R; +import io.github.emanual.app.api.EmanualAPI; +import io.github.emanual.app.entity.FeedsItemEntity; +import io.github.emanual.app.ui.adapter.FeedsListAdapter; +import io.github.emanual.app.ui.base.activity.SwipeRefreshActivity; +import io.github.emanual.app.utils.SwipeRefreshLayoutUtils; +import timber.log.Timber; + +public class InterviewFeedsActivity extends SwipeRefreshActivity { + + ProgressDialog mProgressDialog; + @Bind(R.id.recyclerView) RecyclerView recyclerView; + + @Override protected void initData(Bundle savedInstanceState) { + + } + + @Override protected void initLayout(Bundle savedInstanceState) { + setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setTitle(R.string.acty_feeds_list); + + recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); + + fetchData(); + } + + @Override protected int getContentViewId() { + return R.layout.acty_interview_feeds; + } + + @Override public void onRefresh() { +// EmanualAPI.getIn + fetchData(); + } + + private void fetchData() { + EmanualAPI.getInterviewFeeds(new AsyncHttpResponseHandler() { + @Override public void onStart() { + super.onStart(); + SwipeRefreshLayoutUtils.setRefreshing(getSwipeRefreshLayout(), true); + } + + @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { + try { + List feeds = FeedsItemEntity.createByJSONArray(new String(responseBody), FeedsItemEntity.class); + Timber.d(feeds.toString()); + recyclerView.setAdapter(new FeedsListAdapter(getContext(), feeds)); + } catch (Exception e) { + toast("哎呀,网络异常!"); + } + } + + @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { + } + + @Override public void onFinish() { + super.onFinish(); + SwipeRefreshLayoutUtils.setRefreshing(getSwipeRefreshLayout(), false); + } + + @Override public void onProgress(long bytesWritten, long totalSize) { + super.onProgress(bytesWritten, totalSize); + + } + }); + } + +} diff --git a/app/src/main/java/io/github/emanual/app/ui/fragment/ExploreFragment.java b/app/src/main/java/io/github/emanual/app/ui/fragment/ExploreFragment.java index 8e9f8f5..9579eb9 100644 --- a/app/src/main/java/io/github/emanual/app/ui/fragment/ExploreFragment.java +++ b/app/src/main/java/io/github/emanual/app/ui/fragment/ExploreFragment.java @@ -17,6 +17,7 @@ import io.github.emanual.app.ui.BrowserActivity; import io.github.emanual.app.ui.FeedbackActivity; import io.github.emanual.app.ui.BookFeedsListActivity; +import io.github.emanual.app.ui.InterviewFeedsActivity; import io.github.emanual.app.ui.base.fragment.BaseFragment; import io.github.emanual.app.utils.EManualUtils; @@ -97,10 +98,14 @@ public void onUpdateReturned(int updateStatus,UpdateResponse updateInfo) { startActivity(intent); } - @OnClick(R.id.btn_feeds) public void feeds(){ + @OnClick(R.id.btn_feeds) public void bookFeeds(){ Intent intent = new Intent(getActivity(), BookFeedsListActivity.class); startActivity(intent); } - + @OnClick(R.id.btn_interview) + public void interviewFeeds(){ + Intent intent = new Intent(getActivity(), InterviewFeedsActivity.class); + startActivity(intent); + } } diff --git a/app/src/main/res/layout/acty_interview_feeds.xml b/app/src/main/res/layout/acty_interview_feeds.xml new file mode 100644 index 0000000..ad120c7 --- /dev/null +++ b/app/src/main/res/layout/acty_interview_feeds.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_explore.xml b/app/src/main/res/layout/fragment_explore.xml index 6ee34f5..d91f9e6 100644 --- a/app/src/main/res/layout/fragment_explore.xml +++ b/app/src/main/res/layout/fragment_explore.xml @@ -12,7 +12,29 @@ + + + + + + + + + + android:text="笔试资源下载"/> > + diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..63fc816 --- /dev/null +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 43227f1..f1b829e 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -13,5 +13,6 @@ 0dp + 16dp \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d1eed07..9674d89 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,4 +23,5 @@ 浏览 资源下载 Settings + InterviewFeedsActivity \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index fe3275f..98d5a3f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -129,4 +129,8 @@ center +