Skip to content

Commit

Permalink
support list
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayin committed Feb 22, 2016
1 parent 331744c commit c55ae41
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 10 deletions.
12 changes: 8 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="io.github.emanual.app"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<manifest package="io.github.emanual.app"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand Down Expand Up @@ -86,6 +85,11 @@
android:value="${UMENG_CHANNEL_VALUE}"/>
<!-- Umeng End -->

<activity
android:name=".ui.InterviewFeedsActivity"
android:label="@string/title_activity_interview_feeds"
android:theme="@style/AppTheme">
</activity>
</application>

</manifest>
10 changes: 9 additions & 1 deletion app/src/main/java/io/github/emanual/app/api/EmanualAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<FeedsItemEntity> 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);

}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
44 changes: 44 additions & 0 deletions app/src/main/res/layout/acty_interview_feeds.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/layout_container"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.InterviewFeedsActivity"
>

<io.github.emanual.app.widget.SwipeBackLayout
android:id="@+id/swipBackLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
>

<include layout="@layout/toolbar"/>

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/adapter_feedslist">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>

</io.github.emanual.app.widget.SwipeBackLayout>

</LinearLayout>
28 changes: 25 additions & 3 deletions app/src/main/res/layout/fragment_explore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,37 @@

<com.beardedhen.androidbootstrap.AwesomeTextView
style="@style/AndroidBootstrap.FontAwesomeText"
app:fontAwesomeIcon="fa_building"
app:fontAwesomeIcon="fa_cloud_download"
/>

<TextView
style="@style/TextView.newfeed"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:gravity="left"
android:text="教程资源下载"/>
</LinearLayout>

<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@drawable/ic_line_1"/>

<LinearLayout
android:id="@+id/btn_interview"
style="@style/Linerlayout.explore">

<com.beardedhen.androidbootstrap.AwesomeTextView
style="@style/AndroidBootstrap.FontAwesomeText"
app:fontAwesomeIcon="fa_cloud_download"
/>

<TextView
style="@style/TextView.newfeed"
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:gravity="left"
android:text="资源下载"/>
android:text="笔试资源下载"/>
</LinearLayout>

<View
Expand Down Expand Up @@ -122,7 +144,7 @@

<com.beardedhen.androidbootstrap.AwesomeTextView
style="@style/AndroidBootstrap.FontAwesomeText"
app:fontAwesomeIcon="fa_cloud_download"
app:fontAwesomeIcon="fa_refresh"
/>

<TextView
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-v21/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<resources>>
</resources>
6 changes: 6 additions & 0 deletions app/src/main/res/values-w820dp/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@

<!-- Toolbar -->
<dimen name="toobal_padingTop">0dp</dimen>
<dimen name="fab_margin">16dp</dimen>

</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
<string name="acty_browser">浏览</string>
<string name="acty_feeds_list">资源下载</string>
<string name="action_settings">Settings</string>
<string name="title_activity_interview_feeds">InterviewFeedsActivity</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,8 @@
<item name="android:gravity">center</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>

</resources>

1 comment on commit c55ae41

@Jayin
Copy link
Member Author

@Jayin Jayin commented on c55ae41 Feb 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#67

Please sign in to comment.