-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
190 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
app/src/main/java/io/github/emanual/app/ui/InterviewFeedsActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<resources>> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
|
||
<!-- Toolbar --> | ||
<dimen name="toobal_padingTop">0dp</dimen> | ||
<dimen name="fab_margin">16dp</dimen> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c55ae41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#67