Skip to content

Commit

Permalink
提醒线自定义,版本变更为v0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hanFengSan committed Aug 7, 2016
1 parent 0d8491f commit 04080c5
Show file tree
Hide file tree
Showing 16 changed files with 396 additions and 20 deletions.
14 changes: 7 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.0') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
// androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
// androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.0') {
// exclude group: 'com.android.support', module: 'appcompat'
// exclude group: 'com.android.support', module: 'support-v4'
// exclude module: 'recyclerview-v7'
// }
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
Expand Down
Binary file renamed app/app-release.apk → app/light-v0-2测试版.apk
Binary file not shown.
Binary file added app/light-v0-2测试版= =.apk
Binary file not shown.
40 changes: 36 additions & 4 deletions app/src/main/java/com/yakami/light/bean/NotificationProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
public class NotificationProfile extends Entity {

public static final String CACHE_NAME = "NOTIFICATION_PROFILE";
public static final int FISH_LINE = 500; //杂鱼线
public static final float FLY_SCALE = 0.75f; //爆上比例
public static final float DIVE_SCALE = 1.25f; //跳水比例
public static final float TOP = 1; //登顶
private int fishLine = 500; //杂鱼线
private float flyScale = 0.25f; //爆上比例
private float diveScale = 0.25f; //跳水比例
private int top = 1; //登顶

private ArrayList<NotificationItem> mList = new ArrayList<>();

Expand All @@ -33,4 +33,36 @@ public ArrayList<NotificationItem> getList() {
public void setList(ArrayList<NotificationItem> list) {
this.mList = list;
}

public int getFishLine() {
return fishLine;
}

public void setFishLine(int fishLine) {
this.fishLine = fishLine;
}

public float getFlyScale() {
return flyScale;
}

public void setFlyScale(float flyScale) {
this.flyScale = flyScale;
}

public float getDiveScale() {
return diveScale;
}

public void setDiveScale(float diveScale) {
this.diveScale = diveScale;
}

public int getTop() {
return top;
}

public void setTop(int top) {
this.top = top;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.List;

import static com.yakami.light.bean.NotificationProfile.CACHE_NAME;
import static com.yakami.light.bean.NotificationProfile.FISH_LINE;
import static com.yakami.light.bean.NotificationProfile.SWITCH_DIVE;
import static com.yakami.light.bean.NotificationProfile.SWITCH_FLY;
import static com.yakami.light.bean.NotificationProfile.SWITCH_IGNORE_FISH;
Expand Down Expand Up @@ -73,7 +72,7 @@ public List<DiscNotificationResult> getAliveList(ArrayList<DiscRank> discList) {
for (NotificationItem tmp : list) {
if (discItem.getId() == tmp.getId()) {
if (tmp.isUpdate() || tmp.isFly() || tmp.isDive() || tmp.isTop() || tmp.isWatched()) {
if (!(tmp.isIgnoreFish() && discItem.getCurrentRank() > FISH_LINE)) {
if (!(tmp.isIgnoreFish() && discItem.getCurrentRank() > mProfile.getFishLine())) {
result.add(new DiscNotificationResult(discItem, tmp));
}
list.remove(tmp);
Expand Down Expand Up @@ -169,6 +168,42 @@ public void pushNotification(NotificationText text, boolean isCopyable) {
}
}

public void setList(ArrayList<NotificationItem> list) {
mProfile.setList(list);
}

public int getFishLine() {
return mProfile.getFishLine();
}

public void setFishLine(int fishLine) {
mProfile.setFishLine(fishLine);
}

public float getFlyScale() {
return mProfile.getFlyScale();
}

public void setFlyScale(float flyScale) {
mProfile.setFlyScale(flyScale);
}

public float getDiveScale() {
return mProfile.getDiveScale();
}

public void setDiveScale(float diveScale) {
mProfile.setDiveScale(diveScale);
}

public int getTop() {
return mProfile.getTop();
}

public void setTop(int top) {
mProfile.setTop(top);
}

public static class NotificationText {

private String title;
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/com/yakami/light/service/PushService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.yakami.light.bean.DiscNotificationResult;
import com.yakami.light.bean.DiscRank;
import com.yakami.light.bean.NotificationItem;
import com.yakami.light.bean.NotificationProfile;
import com.yakami.light.bean.ServerResponse;
import com.yakami.light.bean.Version;
import com.yakami.light.service.base.BaseService;
Expand Down Expand Up @@ -129,6 +128,7 @@ private void updateAll() {
private TitleHelper getContentAndTitle(List<DiscNotificationResult> aliveList) {
mContent = "";
TitleHelper titleHelper = new TitleHelper();
NotificationService service = AppManager.getNotificationService();
//判断是否达到通知条件
for (DiscNotificationResult item : aliveList) {
NotificationItem ni = item.getNotificationItem();
Expand All @@ -141,21 +141,21 @@ private TitleHelper getContentAndTitle(List<DiscNotificationResult> aliveList) {
}
//爆上
if (ni.isFly() && dr.getPreRank() != 0) {
if ((dr.getCurrentRank() / (dr.getPreRank() * 1.0f)) < NotificationProfile.FLY_SCALE) {
if (((dr.getPreRank() - dr.getCurrentRank()) / (dr.getPreRank() * 1.0f)) >= service.getFlyScale()) {
isQualified = true;
titleHelper.pushTitleCandidate(dr.getsName(), TitleHelper.TYPE_FLY, dr.getCurrentRank() / (dr.getPreRank() * 1.0f));
}
}
//跳水
if (ni.isDive() && dr.getPreRank() != 0) {
if ((dr.getCurrentRank() / (dr.getPreRank() * 1.0f)) < NotificationProfile.DIVE_SCALE) {
if (((dr.getCurrentRank() - dr.getPreRank()) / (dr.getPreRank() * 1.0f)) >= service.getDiveScale()) {
isQualified = true;
titleHelper.pushTitleCandidate(dr.getsName(), TitleHelper.TYPE_DIVE, dr.getCurrentRank() / (dr.getPreRank() * 1.0f));
}
}
//登顶
if (ni.isTop()) {
if (dr.getCurrentRank() == NotificationProfile.TOP && dr.getCurrentRank() != dr.getPreRank()) {
if (dr.getCurrentRank() <= service.getTop() && dr.getCurrentRank() != dr.getPreRank()) {
isQualified = true;
titleHelper.pushTitleCandidate(dr.getsName(), TYPE_TOP, 0);
}
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/com/yakami/light/view/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -47,6 +46,7 @@
import com.yakami.light.view.fragment.AboutFragment;
import com.yakami.light.view.fragment.InstructionFragment;
import com.yakami.light.view.fragment.RankDialogFragment;
import com.yakami.light.view.fragment.SettingsFragment;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -114,8 +114,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mScrollY += dy;
int tmp = mScrollY / 2;
Log.e("tmp", tmp + "");
// //为了避免drawables间共享状态导致锁状态问题,得先使用mutate()进行变种处理
//为了避免drawables间共享状态导致锁状态问题,得先使用mutate()进行变种处理
mToolbar.getBackground().mutate().setAlpha(tmp > 255 ? 255 : tmp);
mStatusBarBg.getBackground().mutate().setAlpha(tmp > 255 ? 255 : tmp);
}
Expand Down Expand Up @@ -312,6 +311,8 @@ protected void initDrawer() {
new DividerDrawerItem(),
new PrimaryDrawerItem().withIdentifier(7).withName(mRes.getString(R.string.remove_all_notification)).withOnDrawerItemClickListener(this),
new DividerDrawerItem(),
new PrimaryDrawerItem().withIdentifier(11).withName(R.string.other_settings).withOnDrawerItemClickListener(this),
new DividerDrawerItem(),
new PrimaryDrawerItem().withIdentifier(8).withName(R.string.share).withOnDrawerItemClickListener(this),
new PrimaryDrawerItem().withIdentifier(9).withName(R.string.instruction).withOnDrawerItemClickListener(this),
new PrimaryDrawerItem().withIdentifier(10).withName(R.string.about).withOnDrawerItemClickListener(this))
Expand Down Expand Up @@ -345,6 +346,12 @@ public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
.putString("title", mRes.getString(R.string.about))
.toIntent());
return true;
case 11: //other settings
startActivity(IntentHelper.newInstance(mActivityContext, SingleFragmentActivity.class)
.putString("class", SettingsFragment.class.toString())
.putString("title", mRes.getString(R.string.other_settings))
.toIntent());
return true;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
ButterKnife.bind(this,view);

mAbout.setText("版本: " + BuildConfig.VERSION_NAME + "\n" + mRes.getString(R.string.author));
mAbout.append("\ngithub地址:https://github.com/hanFengSan/light");
return view;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.yakami.light.view.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

import com.jakewharton.rxbinding.view.RxView;
import com.rey.material.widget.Button;
import com.rey.material.widget.EditText;
import com.rey.material.widget.Spinner;
import com.yakami.light.AppManager;
import com.yakami.light.R;
import com.yakami.light.service.NotificationService;
import com.yakami.light.utils.Tools;
import com.yakami.light.view.fragment.base.BaseFragment;

import java.util.concurrent.TimeUnit;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
* Created by Yakami on 2016/8/7, enjoying it!
* 爆上比例、杂鱼线等的用户自定义
*/

public class SettingsFragment extends BaseFragment {

@Bind(R.id.fly_spinner) Spinner mFlySpinner;
@Bind(R.id.dive_spinner) Spinner mDiveSpinner;
@Bind(R.id.fish_line) EditText mFishLineEdit;
@Bind(R.id.top_line) EditText mTopLineEdit;
@Bind(R.id.button_completed) Button mButton;

private float mFlyScale = 0.25f;
private float mDiveScale = 0.25f;

ArrayAdapter<String> mAdapter;

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment__settings, container, false);
ButterKnife.bind(this, view);

init();

return view;
}

private void init() {
//设置项
String[] array = new String[8];
for (int i = 0; i < 8; i++) {
array[i] = (i + 1) * 25 + "%";
}
mAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, array);
mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mFlySpinner.setAdapter(mAdapter);
mDiveSpinner.setAdapter(mAdapter);
//初始化
NotificationService service = AppManager.getNotificationService();
mFlySpinner.setSelection((int) (service.getFlyScale() * 100 / 25 - 1));
mDiveSpinner.setSelection((int) (service.getDiveScale() * 100 / 25 - 1));
mFishLineEdit.setText(service.getFishLine() + "");
mTopLineEdit.setText(service.getTop() + "");
//监听
mFlySpinner.setOnItemSelectedListener((parent, view, position, id) -> mFlyScale = (position + 1) * 25 / 100f);
mDiveSpinner.setOnItemSelectedListener((parent, view, position, id) -> mDiveScale = (position + 1) * 25 / 100f);
RxView.clicks(mButton)
.throttleFirst(500, TimeUnit.MILLISECONDS)
.subscribe(aVoid -> {
service.setFlyScale(mFlyScale);
service.setDiveScale(mDiveScale);
service.setFishLine(Integer.valueOf(mFishLineEdit.getText().toString()));
service.setTop(Integer.valueOf(mTopLineEdit.getText().toString()));
service.save();
Tools.toast(mRes.getString(R.string.setting_ok));
getActivity().finish();
});
}

}
1 change: 1 addition & 0 deletions app/src/main/res/layout/app_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStartWithNavigation="0dp"
android:background="@color/PeterRiver"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways|snap">
Expand Down
Loading

0 comments on commit 04080c5

Please sign in to comment.