Skip to content

Commit

Permalink
Merge pull request #2 from zubinxiong/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
zubinxiong authored Sep 2, 2016
2 parents c348807 + a33e4dd commit f818429
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 36 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ dependencies {
compile rootProject.ext.dependencies["bugly"]

compile rootProject.ext.dependencies["easypermissions"]
compile rootProject.ext.dependencies["discrete-seekbar"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.view.GravityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatSeekBar;
import android.support.v7.widget.AppCompatSpinner;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
Expand All @@ -37,6 +38,7 @@

import com.squareup.picasso.Picasso;

import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

Expand Down Expand Up @@ -633,17 +635,36 @@ private void showEvaluationDialog() {
spinner.setAdapter(spinnerAdapter);

// 评分
final TextInputLayout mRatingNumber = (TextInputLayout) itemView.findViewById(R.id.rate_number);
final TextView mSeekBarTitle = (TextView) itemView.findViewById(R.id.rating_title);
final DiscreteSeekBar mSeekBar = (DiscreteSeekBar) itemView.findViewById(R.id.rating_seekbar);
mSeekBar.setOnProgressChangeListener(new DiscreteSeekBar.OnProgressChangeListener() {
@Override
public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
String text = getString(R.string.rate_number_hint) + ": " + value;
mSeekBarTitle.setText(text);
}

@Override
public void onStartTrackingTouch(DiscreteSeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(DiscreteSeekBar seekBar) {

}
});

// 详情
final TextInputLayout mRatingDetail = (TextInputLayout) itemView.findViewById(R.id.rate_detail);

if (mSubjectComment != null) {
if (mSubjectComment.getRating() != 0) {
mRatingNumber.getEditText().setText(mSubjectComment.getRating() + "");
mSeekBar.setProgress(mSubjectComment.getRating());
}
mRatingDetail.getEditText().setText(mSubjectComment.getComment());


if (mSubjectComment.getStatus() != null) {
spinner.setSelection(mSubjectComment.getStatus().getId() - 1);
}
Expand All @@ -664,15 +685,8 @@ public void onClick(final DialogInterface dialog, int which) {

String[] status = getResources().getStringArray(R.array.spinner_value);
int index = spinner.getSelectedItemPosition();
int rating = 0;
if(!TextUtils.isEmpty(mRatingNumber.getEditText().getText().toString().trim())) {
rating = Integer.parseInt(mRatingNumber.getEditText().getText().toString().trim());
}
if (rating > 10) {
ToastUtils.showShortToast(BangumiDetailActivity.this, R.string.rating_number_max);
mRatingNumber.getEditText().setText("");
return;
}
int rating = mSeekBar.getProgress();
LogUtil.d(LogUtil.ZUBIN, "rating = " + rating);
String comment = mRatingDetail.getEditText().getText().toString().trim();

sBangumi.updateComment(mBangumiId, status[index], rating, comment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ public void onCalendarClick(View view, BangumiCalendar calendar) {
}

private void setupSwipeRefreshLayout() {
mSwipeRefreshLayout.setColorSchemeResources(R.color.refresh_progress_1,
R.color.refresh_progress_2, R.color.refresh_progress_3);
mSwipeRefreshLayout.setColorSchemeResources(R.color.refresh_progress_1);

mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class MyCollectionFragment extends BaseFragment implements View.OnClickLi
private TextView mEmptyText;
private Button mEmptyButton;
private ProgressBar mProgreebar;
private SwipeRefreshLayout mSwipeRefreshLayout;

private List<MyCollection> mList = new ArrayList<>();
private CollectionAdapter adapter;
Expand All @@ -72,15 +74,18 @@ protected void initView(boolean resued) {
mEmptyText = (TextView) getRootView().findViewById(R.id.empty_text);
mEmptyButton = (Button) getRootView().findViewById(R.id.empty_button);
mProgreebar = (ProgressBar) getRootView().findViewById(R.id.progressbar);
mSwipeRefreshLayout = (SwipeRefreshLayout) getRootView().findViewById(R.id.swipe_refresh_layout);

mEmptyButton.setOnClickListener(this);
LogUtil.d(LogUtil.ZUBIN, "cf initview");
setupToolbar();
setupRecyclerview();
setupRefreshLayout();
}

private void requestDataRefresh() {
if (LoginManager.isLogin(getActivity())) {
mSwipeRefreshLayout.setEnabled(true);
mEmptyButton.setVisibility(View.GONE);
mEmptyText.setVisibility(View.GONE);
BaseActivity.sBangumi.getUserCollection(LoginManager.getUserId(getActivity())).enqueue(new Callback<List<MyCollection>>() {
Expand Down Expand Up @@ -154,6 +159,40 @@ public boolean onMenuItemClick(MenuItem item) {
});
}

private void setupRefreshLayout() {
mSwipeRefreshLayout.setColorSchemeResources(R.color.refresh_progress_1);

if (!LoginManager.isLogin(getActivity())) {
mSwipeRefreshLayout.setEnabled(false);
} else {
mSwipeRefreshLayout.setEnabled(true);
}

mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
BaseActivity.sBangumi.getUserCollection(LoginManager.getUserId(getActivity())).enqueue(new Callback<List<MyCollection>>() {

@Override
public void onResponse(Call<List<MyCollection>> call, Response<List<MyCollection>> response) {
if (response.isSuccessful() && response.body() != null) {
mList.clear();
mList.addAll(response.body());
adapter.notifyDataSetChanged();
}
mSwipeRefreshLayout.setRefreshing(false);
}

@Override
public void onFailure(Call<List<MyCollection>> call, Throwable t) {
mSwipeRefreshLayout.setRefreshing(false);
// ToastUtils.showShortToast(getActivity(), R.string.update_failed);
}
});
}
});
}

@Override
public void onClick(View v) {
switch (v.getId()) {
Expand All @@ -180,6 +219,8 @@ public void onLougout(LogoutEvent event) {
mList.clear();
adapter.notifyDataSetChanged();
mProgreebar.setVisibility(View.VISIBLE);
mSwipeRefreshLayout.setRefreshing(false);
mSwipeRefreshLayout.setEnabled(false);
requestDataRefresh();
}

Expand Down
19 changes: 14 additions & 5 deletions app/src/main/res/layout/fragment_my_collection.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@
<include
layout="@layout/toolbar" />

<android.support.v7.widget.RecyclerView
android:id="@+id/collection_recyclerview"
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_below="@+id/toolbar"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/collection_recyclerview"
android:layout_below="@+id/toolbar"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />


</android.support.v4.widget.SwipeRefreshLayout>

<!--用来显示空白是的按钮,包括未登录时的按钮文字,空白是的按钮文字 -->
<TextView
Expand Down
31 changes: 20 additions & 11 deletions app/src/main/res/layout/view_evaluation.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="@dimen/common_padding"
android:layout_width="match_parent"
Expand All @@ -19,20 +20,27 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<android.support.design.widget.TextInputLayout
android:id="@+id/rate_number"
android:layout_marginTop="10dp"
<TextView
android:id="@+id/rating_title"
android:textSize="12sp"
android:paddingLeft="6dp"
android:text="@string/rate_number_hint"
android:textColor="@color/colorAccent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content" />

<EditText
android:inputType="number"
android:hint="@string/rate_number_hint"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

</android.support.design.widget.TextInputLayout>
<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
android:id="@+id/rating_seekbar"
app:dsb_min="0"
app:dsb_max="10"
app:dsb_indicatorColor="@color/colorAccent"
app:dsb_progressColor="@color/colorAccent"
android:layout_marginLeft="-6dp"
android:layout_marginRight="-6dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


<android.support.design.widget.TextInputLayout
android:id="@+id/rate_detail"
Expand All @@ -42,6 +50,7 @@

<EditText
android:inputType="textMultiLine"
android:layout_marginLeft="4dp"
android:hint="@string/rate_text_hint"
android:scrollHorizontally="false"
android:layout_width="match_parent"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/view_my_collection_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
android:textColor="@color/calendar_title_color"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
<color name="secondPrimaryText">#757575</color>
<color name="border">#BDBDBD</color>

<color name="refresh_progress_1">#e91e63</color>
<color name="refresh_progress_2">#00b0ff</color>
<color name="refresh_progress_3">@color/colorPrimary</color>
<color name="refresh_progress_1">@color/colorPrimary</color>


<color name="calendar_title_color">#424242</color>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<string name="bangumi_detail_air_day">放送日期: %1$s</string>
<string name="cancel">取消</string>
<string name="submit">提交</string>
<string name="rate_number_hint">评分(0-10分)</string>
<string name="rate_number_hint">评分</string>
<string name="rate_text_hint">我要吐槽</string>
<string name="want_see">状态</string>
<string name="update_comment">评论已提交</string>
Expand Down
7 changes: 4 additions & 3 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ ext {
buildToolsVersion : "23.0.2",
minSdkVersion : 17,
targetSdkVersion : 23,
versionCode : 3,
versionName : "1.1.1"
versionCode : 4,
versionName : "1.2"
]

dependencies = [
Expand All @@ -22,6 +22,7 @@ ext {
"circleimageview" : "de.hdodenhof:circleimageview:2.1.0",
"customtabs" : "com.android.support:customtabs:23.3.0",
"bugly" : "com.tencent.bugly:crashreport:latest.release",
"easypermissions" : "pub.devrel:easypermissions:0.1.9"
"easypermissions" : "pub.devrel:easypermissions:0.1.9",
"discrete-seekbar" : "org.adw.library:discrete-seekbar:1.0.1"
]
}

0 comments on commit f818429

Please sign in to comment.