list) {
30 | getView().showData(list);
31 | }
32 |
33 | @Override
34 | public void onError(Throwable e) {
35 | getView().showError();
36 | }
37 |
38 | @Override
39 | public void onComplete() {
40 |
41 | }
42 | };
43 | contentGankData.getDailyGankDataFromServer(date, observer);
44 | }
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/presenter/IPresenter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.presenter;
2 |
3 | /**
4 | * Created by wavever on 2016/8/30.
5 | */
6 | public interface IPresenter {
7 | P createPresenter();
8 |
9 | P getPresenter();
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/presenter/LikePresenter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.presenter;
2 |
3 | import com.activeandroid.query.Select;
4 | import java.util.List;
5 | import me.wavever.ganklock.model.bean.Gank;
6 | import me.wavever.ganklock.utils.LogUtil;
7 | import me.wavever.ganklock.view.ILikeView;
8 |
9 | /**
10 | * Created by wavever on 2016/9/2.
11 | */
12 | public class LikePresenter extends BasePresenter{
13 |
14 | private static final String TAG = LikePresenter.class.getSimpleName()+"-->";
15 |
16 | public void getLikeList(){
17 | List list = new Select().from(Gank.class).execute();
18 | for(Gank gank:list){
19 | LogUtil.d(TAG+"收藏"+gank.getDesc());
20 | }
21 | if(list == null || list.isEmpty()){
22 | getView().showEmptyTip();
23 | }else {
24 | getView().showLikeData(list);
25 | }
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/presenter/LockPresenter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.presenter;
2 |
3 | import me.wavever.ganklock.view.ILockView;
4 |
5 | public class LockPresenter extends BasePresenter {
6 | }
7 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/presenter/MeiZhiPresenter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.presenter;
2 |
3 | import android.os.Environment;
4 | import java.io.File;
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | import io.reactivex.Observer;
9 | import io.reactivex.android.schedulers.AndroidSchedulers;
10 | import io.reactivex.disposables.Disposable;
11 | import io.reactivex.functions.Predicate;
12 | import io.reactivex.schedulers.Schedulers;
13 | import me.wavever.ganklock.view.IMeiZhiView;
14 | import io.reactivex.Observable;
15 |
16 | /**
17 | * Created by wavever on 2016/9/2.
18 | */
19 | public class MeiZhiPresenter extends BasePresenter {
20 |
21 | private static final String TAG = "MeiZhiPresenter-->";
22 |
23 | private List mList = new ArrayList<>();
24 |
25 | public void loadMeizhi() {
26 | File fileDir = new File(Environment.getExternalStorageDirectory(), "GankLock");
27 | if (!fileDir.exists()||fileDir.listFiles().length==0) {
28 | getView().showEmptyView();
29 | return;
30 | }
31 | if(!mList.isEmpty()){
32 | mList.clear();
33 | }
34 | Observable.fromArray(fileDir.listFiles())
35 | .filter(new Predicate() {
36 | @Override
37 | public boolean test(File file) {
38 | return file.getName().endsWith(".jpg");
39 | }
40 | })
41 | .subscribeOn(Schedulers.io())
42 | .observeOn(AndroidSchedulers.mainThread())
43 | .unsubscribeOn(AndroidSchedulers.mainThread())
44 | .subscribe(new Observer() {
45 | @Override
46 | public void onSubscribe(Disposable d) {
47 |
48 | }
49 |
50 | @Override
51 | public void onNext(File file) {
52 | mList.add(file);
53 | }
54 |
55 | @Override
56 | public void onError(Throwable e) {
57 | }
58 |
59 | @Override
60 | public void onComplete() {
61 | if (getView() != null) {
62 | getView().showMeizhi(mList);
63 | }
64 | }
65 | });
66 | }
67 |
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/presenter/MorePresenter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.presenter;
2 |
3 | import me.wavever.ganklock.view.IMoreView;
4 |
5 | /**
6 | * Created by waveverht on 2016/9/18.
7 | */
8 |
9 | public class MorePresenter extends BasePresenter {
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/presenter/WebViewPresenter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.presenter;
2 |
3 | import me.wavever.ganklock.view.IWebView;
4 |
5 | /**
6 | * Created by wavever. on 2016/10/18.
7 | */
8 |
9 | public class WebViewPresenter extends BasePresenter{
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/receiver/GankLockReceiver.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.receiver;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.telephony.TelephonyManager;
7 | import me.wavever.ganklock.MyApplication;
8 | import me.wavever.ganklock.ui.activity.LockActivity;
9 |
10 | /**
11 | * Created by wavever on 2015/12/24.
12 | */
13 | public class GankLockReceiver extends BroadcastReceiver {
14 |
15 | private static final String TAG = GankLockReceiver.class.getSimpleName();
16 |
17 |
18 | @Override
19 | public void onReceive(Context context, Intent intent) {
20 | String action = intent.getAction();
21 | /*if (action.equals(Intent.ACTION_SCREEN_ON)) {
22 | LockManager.createLockView();
23 | onPhoneRing();
24 | }*/
25 | if (action.equals(Intent.ACTION_SCREEN_OFF)) {
26 | Intent mLockIntent = new Intent(context, LockActivity.class);
27 | mLockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
28 | | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
29 | context.startActivity(mLockIntent);
30 | }
31 | }
32 |
33 |
34 | public void onPhoneRing() {
35 | //手机处于响铃状态
36 | if (((TelephonyManager) MyApplication.getContext()
37 | .getSystemService("phone")).getCallState() == TelephonyManager.CALL_STATE_IDLE) {
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/service/LockService.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.service;
2 |
3 | import android.app.Service;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 | import android.os.IBinder;
8 | import me.wavever.ganklock.config.Config;
9 | import me.wavever.ganklock.receiver.GankLockReceiver;
10 | import me.wavever.ganklock.utils.PreferenceUtil;
11 |
12 | /**
13 | * Created by wavever on 2015/12/26.
14 | */
15 | public class LockService extends Service {
16 |
17 | private BroadcastReceiver receiver;
18 |
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 | IntentFilter intentFilter = new IntentFilter();
23 | intentFilter.addAction(Intent.ACTION_SCREEN_ON);
24 | intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
25 | receiver = new GankLockReceiver();
26 | registerReceiver(receiver, intentFilter);
27 | }
28 |
29 | @Override
30 | public int onStartCommand(Intent intent, int flags, int startId) {
31 | return Service.START_STICKY;
32 | }
33 |
34 | @Override
35 | public void onDestroy() {
36 | super.onDestroy();
37 | if(PreferenceUtil.getBoolean(Config.GANK_LOCK_IS_OPEN)){
38 | //LockManager.startLock(false);
39 | startService(new Intent(LockService.this,LockService.class));
40 | return;
41 | }
42 | unregisterReceiver(receiver);
43 | }
44 |
45 | @Override
46 | public IBinder onBind(Intent intent) {
47 | return null;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 | import me.wavever.ganklock.BuildConfig;
6 | import me.wavever.ganklock.R;
7 |
8 | /**
9 | * Created by wavever on 2016/3/12.
10 | */
11 | public class AboutActivity extends BaseActivity {
12 |
13 | private TextView mTvVersion;
14 |
15 | @Override protected int loadView() {
16 | return R.layout.activity_about;
17 | }
18 |
19 | @Override protected void initView() {
20 | mTvVersion = (TextView) findViewById(R.id.tv_version);
21 | }
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | if (mToolbar != null && getSupportActionBar() != null) {
27 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
28 | }
29 | mTvVersion.setText(getResources().getString(R.string.app_version_code)+BuildConfig.VERSION_NAME);
30 | }
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 | import android.view.MotionEvent;
9 | import me.wavever.ganklock.R;
10 |
11 | /**
12 | * Created by waveverht on 2016/10/19.
13 | */
14 |
15 | public abstract class BaseActivity extends AppCompatActivity{
16 |
17 | protected Toolbar mToolbar;
18 |
19 | protected abstract int loadView();
20 | protected abstract void initView();
21 |
22 |
23 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(loadView());
26 | initToolbar();
27 | initView();
28 | }
29 |
30 | protected void initToolbar() {
31 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
32 | if (mToolbar != null) {
33 | setSupportActionBar(mToolbar);
34 | }
35 | }
36 |
37 | @Override
38 | public boolean onOptionsItemSelected(MenuItem item) {
39 | if (item.getItemId() == android.R.id.home) {
40 | onBackPressed();
41 | return true;
42 | }
43 | return super.onOptionsItemSelected(item);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/BaseMvpActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.os.Bundle;
4 | import me.wavever.ganklock.presenter.BasePresenter;
5 | import me.wavever.ganklock.presenter.IPresenter;
6 |
7 | /**
8 | * Created by wavever on 2015/12/26.
9 | */
10 | public abstract class BaseMvpActivity> extends BaseActivity implements IPresenter {
11 |
12 | protected P mPresenter;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | if (mPresenter == null) {
18 | mPresenter = createPresenter();
19 | mPresenter.attachView((V) this);
20 | }
21 | }
22 |
23 | @Override
24 | public P getPresenter() {
25 | if (mPresenter != null) {
26 | return mPresenter;
27 | }
28 | return null;
29 | }
30 |
31 | @Override
32 | protected void onStart() {
33 | super.onStart();
34 | if (mPresenter != null) {
35 | mPresenter.onActivityLifeStart();
36 | }
37 | }
38 |
39 |
40 | @Override
41 | protected void onResume() {
42 | super.onResume();
43 | }
44 |
45 |
46 | @Override
47 | protected void onPause() {
48 | super.onPause();
49 | }
50 |
51 |
52 | @Override
53 | protected void onStop() {
54 | super.onStop();
55 | }
56 |
57 |
58 | @Override
59 | protected void onDestroy() {
60 | super.onDestroy();
61 | if (mPresenter != null) {
62 | mPresenter.onActivityLifeDestory();
63 | mPresenter.detachView();
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/LicenseActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.app.FragmentManager;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 | import com.artitk.licensefragment.ScrollViewLicenseFragment;
9 | import com.artitk.licensefragment.model.License;
10 | import com.artitk.licensefragment.model.LicenseID;
11 | import com.artitk.licensefragment.model.LicenseType;
12 | import java.util.ArrayList;
13 | import me.wavever.ganklock.R;
14 |
15 | /**
16 | * Created by waveverht on 2016/10/18.
17 | */
18 |
19 | public class LicenseActivity extends BaseActivity {
20 |
21 | @Override protected int loadView() {
22 | return R.layout.fragment_license;
23 | }
24 |
25 |
26 | @Override protected void initView() {
27 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
28 | setTitle(R.string.more_fragment_item_open_source);
29 | if (toolbar != null) {
30 | setSupportActionBar(toolbar);
31 | }
32 | if (getSupportActionBar() != null) {
33 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
34 | }
35 | FragmentManager fragmentManager = getFragmentManager();
36 | ScrollViewLicenseFragment licenseFragment
37 | = (ScrollViewLicenseFragment) fragmentManager.findFragmentById(R.id.fragment_license);
38 | licenseFragment.setLog(true);
39 | licenseFragment.addLicense(
40 | new int[] { LicenseID.GSON, LicenseID.LICENSE_FRAGMENT, LicenseID.OKHTTP,
41 | LicenseID.RETROFIT, LicenseID.PICASSO });
42 | ArrayList customLicenses = new ArrayList<>();
43 | customLicenses.add(
44 | new License(this, "MaterialPreference", LicenseType.MIT_LICENSE, "2015",
45 | "Jens Driller"));
46 | customLicenses.add(
47 | new License(this, "ActiveAndroid", LicenseType.APACHE_LICENSE_20, "2010",
48 | "Michael Pardo"));
49 | customLicenses.add(
50 | new License(this, "MaterialBottomNavigation ", LicenseType.MIT_LICENSE, "2016",
51 | " Alessandro Crugnola"));
52 | customLicenses.add(
53 | new License(this, "PhotoView", LicenseType.APACHE_LICENSE_20, "2011-2012",
54 | "Chris Banes"));
55 | customLicenses.add(
56 | new License(this, "MagicaSakura", LicenseType.APACHE_LICENSE_20, "2016", "Bilibili"));
57 | customLicenses.add(
58 | new License(this, "Android Open Source Project", LicenseType.APACHE_LICENSE_20,
59 | "2009-2012", "Android Open Source Project"));
60 | licenseFragment.addCustomLicense(customLicenses);
61 | }
62 |
63 |
64 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
65 | super.onCreate(savedInstanceState);
66 | }
67 |
68 |
69 | @Override
70 | public boolean onOptionsItemSelected(MenuItem item) {
71 | if (item.getItemId() == android.R.id.home) {
72 | onBackPressed();
73 | return true;
74 | }
75 | return super.onOptionsItemSelected(item);
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/LockActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.graphics.Bitmap;
4 | import android.os.Build.VERSION;
5 | import android.os.Build.VERSION_CODES;
6 | import android.view.View;
7 | import android.view.Window;
8 | import android.view.WindowManager;
9 | import android.view.WindowManager.LayoutParams;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 | import android.widget.ViewSwitcher;
13 | import com.squareup.picasso.Picasso;
14 | import java.io.IOException;
15 |
16 | import io.reactivex.Observable;
17 | import io.reactivex.ObservableEmitter;
18 | import io.reactivex.ObservableOnSubscribe;
19 | import io.reactivex.android.schedulers.AndroidSchedulers;
20 | import io.reactivex.functions.Consumer;
21 | import io.reactivex.schedulers.Schedulers;
22 | import me.wavever.ganklock.R;
23 | import me.wavever.ganklock.presenter.LockPresenter;
24 | import me.wavever.ganklock.ui.widget.SwipeUnLockLayout;
25 | import me.wavever.ganklock.utils.DateUtil;
26 | import me.wavever.ganklock.utils.PreferenceUtil;
27 | import me.wavever.ganklock.view.ILockView;
28 |
29 | /**
30 | * Created by wavever on 2016/10/14.
31 | */
32 |
33 | public class LockActivity extends BaseMvpActivity implements ILockView,SwipeUnLockLayout.OnSwipeListener {
34 |
35 | private static final String TAG = "LockActivity-->";
36 |
37 | private ViewSwitcher mViewSwitcher;
38 | private ImageView mImg;
39 | private TextView mTitle;
40 | private Bitmap bitmap;
41 | private String url;
42 |
43 | @Override protected int loadView() {
44 | return R.layout.activity_lock;
45 | }
46 |
47 | @Override protected void initView() {
48 | getWindow().addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
49 | getWindow().addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
50 | setUI();
51 | SwipeUnLockLayout swipeUnLockLayout = (SwipeUnLockLayout) findViewById(
52 | R.id.slide_layout);
53 | swipeUnLockLayout.setOnSwipeListener(this);
54 | mViewSwitcher = (ViewSwitcher) findViewById(R.id.lock_view_switcher);
55 | mTitle = (TextView) findViewById(R.id.lock_view_gank_title);
56 | TextView mLockViewDate = (TextView) findViewById(R.id.lock_view_date);
57 | final String lockDateText = DateUtil.getLockDateText();
58 | mLockViewDate.setText(lockDateText);
59 | mImg = (ImageView) findViewById(R.id.lock_view_img);
60 | url = PreferenceUtil.getString("url");
61 | if (url.isEmpty()) {
62 | mImg.setImageResource(R.drawable.test_image);
63 | } else {
64 | getBitmap();
65 | }
66 | mImg.setOnClickListener(new View.OnClickListener() {
67 | @Override public void onClick(View v) {
68 | mViewSwitcher.showNext();
69 | }
70 | });
71 |
72 | }
73 |
74 | private void setUI() {
75 | Window window = getWindow();
76 | window.getDecorView().setSystemUiVisibility(
77 | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
78 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
79 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
80 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
81 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
82 | );
83 | if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
84 | window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
85 | }
86 | if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
87 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
88 | //这个属性重复设置会导致NAVIGATION BAR显示
89 | //window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
90 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
91 | window.setStatusBarColor(0);
92 | }
93 | }
94 |
95 | @Override public void onSwipeFinish() {
96 | finish();
97 | }
98 |
99 | @Override public LockPresenter createPresenter() {
100 | return new LockPresenter();
101 | }
102 |
103 | @Override
104 | public void onWindowFocusChanged(boolean hasFocus) {
105 | super.onWindowFocusChanged(hasFocus);
106 | if (hasFocus) {
107 | setUI();
108 | }
109 | }
110 |
111 | private void getBitmap(){
112 |
113 | Observable.create(new ObservableOnSubscribe() {
114 | @Override
115 | public void subscribe(ObservableEmitter emitter) throws Exception {
116 | try {
117 | bitmap = Picasso.with(LockActivity.this).load(url).get();
118 | emitter.onNext(bitmap);
119 | } catch (IOException e) {
120 | e.printStackTrace();
121 | }
122 | }
123 | }).subscribeOn(Schedulers.io())
124 | .observeOn(AndroidSchedulers.mainThread())
125 | .subscribe(new Consumer() {
126 | @Override
127 | public void accept(Bitmap bitmap) throws Exception {
128 | mImg.setImageBitmap(bitmap);
129 | }
130 | });
131 |
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.app.Fragment;
4 | import android.app.FragmentManager;
5 | import android.os.Bundle;
6 | import android.support.annotation.NonNull;
7 | import android.support.design.widget.BottomNavigationView;
8 | import android.support.design.widget.Snackbar;
9 | import android.view.MenuItem;
10 | import android.view.View;
11 | import me.wavever.ganklock.R;
12 | import me.wavever.ganklock.ui.fragment.DailyGankFragment;
13 | import me.wavever.ganklock.ui.fragment.LikeFragment;
14 | import me.wavever.ganklock.ui.fragment.MeizhiFragment;
15 | import me.wavever.ganklock.ui.fragment.MoreFragment;
16 |
17 | /**
18 | * Created by wavever on 2016/5/28.
19 | */
20 | public class MainActivity extends BaseActivity {
21 |
22 | private Fragment mCurrentFragment;
23 | private DailyGankFragment dailyGankFragment;
24 | private LikeFragment likeFragment;
25 | private MeizhiFragment meizhiFragment;
26 | private MoreFragment moreFragment;
27 | private FragmentManager manager;
28 |
29 | private View mContainer;
30 |
31 | private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
32 | = new BottomNavigationView.OnNavigationItemSelectedListener() {
33 |
34 | @Override
35 | public boolean onNavigationItemSelected(@NonNull MenuItem item) {
36 | switch (item.getItemId()) {
37 | case R.id.bbn_daliy:
38 | if (mCurrentFragment != dailyGankFragment) {
39 | if (dailyGankFragment == null) {
40 | dailyGankFragment = DailyGankFragment.getInstance();
41 | }
42 | replaceFragmentByTag(dailyGankFragment);
43 | }
44 | break;
45 | case R.id.bbn_like:
46 | if (mCurrentFragment != likeFragment) {
47 | if (likeFragment == null) {
48 | likeFragment = new LikeFragment();
49 | }
50 | replaceFragmentByTag(likeFragment);
51 | }
52 | break;
53 | case R.id.bbn_meizhi:
54 | if (mCurrentFragment != meizhiFragment) {
55 | if (meizhiFragment == null) {
56 | meizhiFragment = new MeizhiFragment();
57 | }
58 | replaceFragmentByTag(meizhiFragment);
59 | }
60 | break;
61 | case R.id.bbn_more:
62 | if (mCurrentFragment != moreFragment) {
63 | if (moreFragment == null) {
64 | moreFragment = new MoreFragment();
65 | }
66 | replaceFragmentByTag(moreFragment);
67 | }
68 | break;
69 | default:
70 | break;
71 | }
72 | return false;
73 | }
74 | };
75 |
76 | @Override protected int loadView() {
77 | return R.layout.activity_main;
78 | }
79 |
80 |
81 | @Override protected void initView() {
82 | mContainer = findViewById(R.id.main_activity_container);
83 | BottomNavigationView navigation = findViewById(R.id.navigation);
84 | navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
85 | manager = getFragmentManager();
86 | }
87 |
88 |
89 | @Override
90 | protected void onCreate(Bundle savedInstanceState) {
91 | super.onCreate(savedInstanceState);
92 | //解决内存重启导致Fragment重叠的问题
93 | dailyGankFragment = DailyGankFragment.getInstance();
94 | replaceFragmentByTag(dailyGankFragment);
95 | }
96 |
97 |
98 | long time = 0;
99 |
100 | @Override
101 | public void onBackPressed() {
102 | if (System.currentTimeMillis() - time > 2000) {
103 | Snackbar.make(mContainer, R.string.exit_with_two_click, Snackbar.LENGTH_SHORT).show();
104 | time = System.currentTimeMillis();
105 | } else {
106 | super.onBackPressed();
107 | }
108 | }
109 |
110 | public void replaceFragmentByTag(Fragment fragment) {
111 | if (mCurrentFragment == null) {
112 | manager.beginTransaction().add(R.id.main_activity_container, fragment,
113 | fragment.getClass().getSimpleName()).commit();
114 | } else {
115 | if (fragment.isAdded()) {
116 | manager.beginTransaction().hide(mCurrentFragment).show(fragment).commit();
117 | } else {
118 | manager.beginTransaction().hide(mCurrentFragment)
119 | .add(R.id.main_activity_container, fragment,
120 | fragment.getClass().getSimpleName())
121 | .commit();
122 | }
123 | }
124 | mCurrentFragment = fragment;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/SettingActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.app.Fragment;
4 | import android.app.FragmentManager;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.Toolbar;
7 | import android.view.MenuItem;
8 | import me.wavever.ganklock.R;
9 | import me.wavever.ganklock.ui.fragment.SettingFragment;
10 |
11 | /**
12 | * Created by wavever on 2016/2/23.
13 | */
14 | public class SettingActivity extends BaseActivity {
15 |
16 | private Toolbar mToolbar;
17 |
18 |
19 | @Override protected int loadView() {
20 | return R.layout.activity_setting;
21 | }
22 |
23 |
24 | @Override protected void initView() {
25 | mToolbar = (Toolbar) findViewById(R.id.toolbar);
26 | setSupportActionBar(mToolbar);
27 | setTitle(R.string.action_setting);
28 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
29 | }
30 |
31 |
32 | @Override protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | replaceFragment(R.id.setting_container, new SettingFragment());
35 | }
36 |
37 |
38 |
39 | public void replaceFragment(int resId, Fragment fragment) {
40 | FragmentManager manager = getFragmentManager();
41 | manager.beginTransaction().replace(resId, fragment).commit();
42 | }
43 |
44 | @Override
45 | public boolean onOptionsItemSelected(MenuItem item) {
46 | if (item.getItemId() == android.R.id.home) {
47 | onBackPressed();
48 | return true;
49 | }
50 | return super.onOptionsItemSelected(item);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/activity/WebViewActivity.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.activity;
2 |
3 | import android.R.id;
4 | import android.view.KeyEvent;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 | import android.view.View;
8 | import android.webkit.WebChromeClient;
9 | import android.webkit.WebView;
10 | import android.webkit.WebViewClient;
11 | import android.widget.ProgressBar;
12 |
13 | import me.wavever.ganklock.R;
14 | import me.wavever.ganklock.presenter.WebViewPresenter;
15 | import me.wavever.ganklock.view.IWebView;
16 |
17 | import static android.view.View.GONE;
18 |
19 | /**
20 | * Created by wavever on 2016/10/18.
21 | */
22 |
23 | public class WebViewActivity extends BaseMvpActivity
24 | implements IWebView {
25 |
26 | private static final String TAG = WebViewActivity.class.getSimpleName();
27 | public static final String KEY_TITLE = "key_title";
28 | public static final String KEY_URL = "key_url";
29 | private ProgressBar mProgressBar;
30 | private WebView mWebView;
31 | private String mTitle;
32 | private String mUrl;
33 |
34 |
35 | @Override protected int loadView() {
36 | return R.layout.activity_web_view;
37 | }
38 |
39 |
40 | @Override protected void initView() {
41 | mUrl = getIntent().getStringExtra(KEY_URL);
42 | mTitle = getIntent().getStringExtra(KEY_TITLE);
43 | setTitle(mTitle);
44 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
45 | mProgressBar = findViewById(R.id.progress_bar_web_view);
46 | mWebView = findViewById(R.id.web_view);
47 | mWebView.getSettings().setJavaScriptEnabled(true);//支持JavaScript
48 | mWebView.setWebViewClient(new WebViewClient() {
49 | @Override public boolean shouldOverrideUrlLoading(WebView view, String url) {
50 | view.loadUrl(url);
51 | return true;
52 | }
53 | });
54 | mWebView.setWebChromeClient(new WebChromeClient() {
55 | @Override public void onProgressChanged(WebView view, int newProgress) {
56 | if (newProgress <= 90) {
57 | if (mProgressBar.getVisibility() == GONE) {
58 | mProgressBar.setVisibility(View.VISIBLE);
59 | }
60 | mProgressBar.setProgress(newProgress);
61 | } else {
62 | mProgressBar.setVisibility(GONE);
63 | }
64 | super.onProgressChanged(view, newProgress);
65 | }
66 | });
67 | mWebView.loadUrl(mUrl);
68 | }
69 |
70 |
71 | @Override public WebViewPresenter createPresenter() {
72 | return new WebViewPresenter();
73 | }
74 |
75 |
76 | @Override public boolean onCreateOptionsMenu(Menu menu) {
77 | //getMenuInflater().inflate(R.menu.web_view_menu, menu);
78 | return super.onCreateOptionsMenu(menu);
79 | }
80 |
81 |
82 | @Override public boolean onKeyDown(int keyCode, KeyEvent event) {
83 | if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
84 | mWebView.goBack();
85 | return true;
86 | }
87 | return super.onKeyDown(keyCode, event);
88 | }
89 |
90 |
91 | @Override
92 | public boolean onOptionsItemSelected(MenuItem item) {
93 | switch (item.getItemId()) {
94 | case id.home:
95 | onBackPressed();
96 | break;
97 | /*case R.id.action_webview_share:
98 | Intent intent = new Intent();
99 | intent.setAction(Intent.ACTION_SEND);
100 | intent.setType("text/plain");
101 | intent.putExtra(Intent.EXTRA_TEXT,mTitle+mUrl);
102 | startActivity(Intent.createChooser(intent, "分享到"));
103 | break;
104 | case R.id.action_webview_refresh:
105 | mWebView.reload();
106 | break;
107 | case R.id.action_webview_copy_url:
108 | ClipboardManager copy = (ClipboardManager) getSystemService(
109 | Context.CLIPBOARD_SERVICE);
110 | copy.setText(mUrl);
111 | ToastUtil.showToastShort(this, "复制成功");
112 | break;
113 | case R.id.action_webview_open_browser:
114 | mWebView.setWebViewClient(null);
115 | mWebView.loadUrl(mUrl);
116 | break;*/
117 | }
118 | return true;
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/adapter/BaseRVAdapter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView.Adapter;
4 | import android.support.v7.widget.RecyclerView.ViewHolder;
5 | import android.view.ViewGroup;
6 |
7 | /**
8 | * Created by wavever on 2016/9/25.
9 | */
10 |
11 | public class BaseRVAdapter extends Adapter{
12 |
13 | @Override public VH onCreateViewHolder(ViewGroup parent, int viewType) {
14 | return null;
15 |
16 |
17 | }
18 |
19 |
20 | @Override public void onBindViewHolder(VH holder, int position) {
21 |
22 | }
23 |
24 |
25 | @Override public int getItemCount() {
26 | return 0;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/adapter/DailyListAdapter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.adapter;
2 |
3 | import android.app.Activity;
4 | import android.support.v7.widget.RecyclerView.Adapter;
5 | import android.support.v7.widget.RecyclerView.ViewHolder;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.View.OnClickListener;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 | import com.squareup.picasso.Picasso;
13 | import java.util.List;
14 | import me.wavever.ganklock.R;
15 | import me.wavever.ganklock.event.ClickEvent;
16 | import me.wavever.ganklock.event.RxBus;
17 | import me.wavever.ganklock.model.bean.GankDaily;
18 | import me.wavever.ganklock.utils.DateUtil;
19 |
20 | /**
21 | * Created by wavever on 2016/9/8.
22 | */
23 | public class DailyListAdapter extends Adapter {
24 |
25 | private static final String TAG = DailyListAdapter.class.getSimpleName()+"-->";
26 |
27 | private static final int TYPE_DAILY = 0;
28 | private static final int TYPE_FOOTER = 1;
29 |
30 | private List mDatas;
31 | private Activity mContext;
32 |
33 | public DailyListAdapter(List datas,Activity context) {
34 | mDatas = datas;
35 | mContext = context;
36 | }
37 |
38 | @Override
39 | public DailyListViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {//设置为null会导致宽度高度失效--》parent
40 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_daily_recycler_view,parent,false);
41 | return new DailyListViewHolder(view);
42 | }
43 |
44 | @Override
45 | public void onBindViewHolder(DailyListViewHolder holder, int position) {
46 | holder.gankDaily = mDatas.get(position);
47 | holder.title.setText(mDatas.get(position).title);
48 | holder.date.setText(DateUtil.convertDateNum(mDatas.get(position).publishedAt));
49 | Picasso.with(mContext).load(mDatas.get(position).content).into(holder.img);
50 | }
51 |
52 | @Override
53 | public int getItemCount() {
54 | return mDatas == null ? 0 : mDatas.size();
55 | }
56 |
57 |
58 | @Override public int getItemViewType(int position) {
59 | return super.getItemViewType(position);
60 | }
61 |
62 | public class DailyListViewHolder extends ViewHolder{
63 |
64 | GankDaily gankDaily;
65 | ImageView img;
66 | TextView title;
67 | TextView date;
68 | ImageView newTag;
69 |
70 | public DailyListViewHolder(View itemView) {
71 | super(itemView);
72 | img = (ImageView) itemView.findViewById(R.id.daily_item_image);
73 | img.setOnClickListener(new OnClickListener() {
74 | @Override public void onClick(View v) {
75 | RxBus.getInstance().post(new ClickEvent(ClickEvent.CLICK_TYPE_DAILY_PHOTO,gankDaily));
76 | }
77 | });
78 | date = (TextView) itemView.findViewById(R.id.daily_item_date);
79 | title = (TextView) itemView.findViewById(R.id.daily_item_title);
80 | title.setOnClickListener(new OnClickListener() {
81 | @Override public void onClick(View v) {
82 | RxBus.getInstance().post(new ClickEvent(ClickEvent.CLICK_TYPE_DAILY_TITLE,gankDaily));
83 | }
84 | });
85 | newTag = (ImageView) itemView.findViewById(R.id.daily_item_new_tag);
86 | }
87 |
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/adapter/GankListAdapter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.CardView;
5 | import android.support.v7.widget.RecyclerView.Adapter;
6 | import android.support.v7.widget.RecyclerView.ViewHolder;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 | import com.activeandroid.query.Select;
13 | import java.util.List;
14 | import me.wavever.ganklock.R;
15 | import me.wavever.ganklock.model.bean.Gank;
16 | import me.wavever.ganklock.ui.adapter.GankListAdapter.GankListHolder;
17 | import me.wavever.ganklock.ui.widget.ColorfulCircleView;
18 |
19 | /**
20 | * Created by wavever on 2016/3/5.
21 | */
22 | public class GankListAdapter extends Adapter {
23 |
24 | private List mList;
25 | private Context mContext;
26 | private OnItemClickListener onItemClickListener;
27 |
28 | private final int ITEM_CATEGORY = 0;
29 | private final int ITEM_TITLE = 1;
30 |
31 |
32 | public GankListAdapter(Context context, List list) {
33 | mContext = context;
34 | mList = list;
35 | }
36 |
37 |
38 | public void setOnItemClickListener(GankListAdapter.OnItemClickListener onItemClickListener) {
39 | this.onItemClickListener = onItemClickListener;
40 | }
41 |
42 |
43 | @Override
44 | public GankListHolder onCreateViewHolder(ViewGroup parent, int viewType) {
45 | View view = LayoutInflater.from(parent.getContext())
46 | .inflate(R.layout.item_gank_rv_content, parent, false);
47 | if (viewType == ITEM_CATEGORY) {
48 | return new GankListHolder(view, true);
49 | } else {
50 | return new GankListHolder(view, false);
51 | }
52 | }
53 |
54 |
55 | @Override public void onBindViewHolder(GankListHolder holder, int position) {
56 | Gank gank = mList.get(position);
57 | holder.setIsRecyclable(false);
58 | holder.gank = gank;
59 | holder.category.setText(gank.getType());
60 | holder.ccv.setText(gank.getWho());
61 | holder.who.setText(gank.getWho());
62 | holder.desc.setText(gank.getDesc());
63 | if (new Select().from(Gank.class).where("_id=?", gank.get_id()).exists()) {
64 | holder.like.setImageResource(R.drawable.ic_favorite_red_500_24dp);
65 | }
66 | }
67 |
68 |
69 | @Override public int getItemViewType(int position) {
70 | if (position == 0) {
71 | return ITEM_CATEGORY;
72 | } else {
73 | boolean isSame = mList.get(position - 1)
74 | .getType()
75 | .equals(mList.get(position).getType());
76 | if (!isSame) {
77 | return ITEM_CATEGORY;
78 | } else {
79 | return ITEM_TITLE;
80 | }
81 | }
82 | }
83 |
84 |
85 | @Override public int getItemCount() {
86 | return mList.size();
87 | }
88 |
89 |
90 | class GankListHolder extends ViewHolder implements View.OnClickListener {
91 |
92 | Gank gank;
93 | CardView cardView;
94 | TextView category;
95 | ColorfulCircleView ccv;
96 | TextView who;
97 | ImageView like;
98 | ImageView share;
99 | TextView desc;
100 |
101 |
102 | public GankListHolder(View itemView, boolean isShow) {
103 | super(itemView);
104 | cardView = (CardView) itemView.findViewById(R.id.item_gank_card_view);
105 | cardView.setOnClickListener(this);
106 | category = (TextView) itemView.findViewById(R.id.item_gank_category);
107 | ccv = (ColorfulCircleView) itemView.findViewById(R.id.item_gank_ccv);
108 | who = (TextView) itemView.findViewById(R.id.item_gank_who);
109 | like = (ImageView) itemView.findViewById(R.id.item_gank_like);
110 | like.setOnClickListener(this);
111 | share = (ImageView) itemView.findViewById(R.id.item_gank_share);
112 | share.setOnClickListener(this);
113 | desc = (TextView) itemView.findViewById(R.id.item_gank_desc);
114 | if (isShow) {
115 | category.setVisibility(View.VISIBLE);
116 | } else {
117 | category.setVisibility(View.GONE);
118 | }
119 | }
120 |
121 |
122 | @Override public void onClick(View v) {
123 | onItemClickListener.onItemClick(v, cardView, like, share, gank);
124 | }
125 |
126 | }
127 |
128 |
129 | public interface OnItemClickListener {
130 | void onItemClick(View view, View layout, ImageView like, ImageView share, Gank gank);
131 | }
132 | }
133 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/adapter/LikeRecyclerViewAdapter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView.Adapter;
5 | import android.support.v7.widget.RecyclerView.ViewHolder;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 | import java.util.List;
12 | import me.wavever.ganklock.R;
13 | import me.wavever.ganklock.event.ClickEvent;
14 | import me.wavever.ganklock.event.RxBus;
15 | import me.wavever.ganklock.model.bean.Gank;
16 | import me.wavever.ganklock.ui.adapter.LikeRecyclerViewAdapter.LikeViewHolder;
17 | import me.wavever.ganklock.ui.widget.ColorfulCircleView;
18 | import me.wavever.ganklock.utils.DateUtil;
19 |
20 | /**
21 | * Created by waveverhon 2016/10/13.
22 | */
23 |
24 | public class LikeRecyclerViewAdapter extends Adapter {
25 |
26 | private Context mContext;
27 | private List mList;
28 |
29 | public LikeRecyclerViewAdapter(Context context) {
30 | mContext = context;
31 | }
32 |
33 |
34 | public void setDataList(List list) {
35 | mList = list;
36 | }
37 |
38 |
39 | @Override
40 | public LikeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
41 | View view = LayoutInflater.from(parent.getContext())
42 | .inflate(R.layout.item_like_rv, parent, false);
43 | return new LikeViewHolder(view);
44 | }
45 |
46 |
47 | @Override
48 | public void onBindViewHolder(LikeViewHolder holder, int position) {
49 | holder.position = position;
50 | holder.type.setText(mList.get(position).getType());
51 | holder.ccv.setText(mList.get(position).getType());
52 | holder.desc.setText(mList.get(position).getDesc());
53 | holder.date.setText(DateUtil.formatDate(mList.get(position).getPublishedAt()));
54 | }
55 |
56 |
57 | @Override public int getItemCount() {
58 | return mList == null ? 0 : mList.size();
59 | }
60 |
61 |
62 | class LikeViewHolder extends ViewHolder {
63 |
64 | LinearLayout layout;
65 | int position;
66 | ColorfulCircleView ccv;
67 | TextView type;
68 | TextView desc;
69 | TextView date;
70 |
71 | public LikeViewHolder(View itemView) {
72 | super(itemView);
73 | layout = (LinearLayout) itemView.findViewById(R.id.item_like_layout);
74 | layout.setOnClickListener(new View.OnClickListener() {
75 | @Override public void onClick(View v) {
76 | RxBus.getInstance().post(new ClickEvent(ClickEvent.CLICK_TYPE_LIKE,position));
77 | }
78 | });
79 | ccv = (ColorfulCircleView) itemView.findViewById(R.id.item_like_ccv);
80 | type = (TextView) itemView.findViewById(R.id.item_like_type);
81 | desc = (TextView) itemView.findViewById(R.id.item_like_desc);
82 | date = (TextView) itemView.findViewById(R.id.item_like_date);
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/adapter/MeizhiRecyclerViewAdapter.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView.Adapter;
5 | import android.support.v7.widget.RecyclerView.ViewHolder;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import com.squareup.picasso.Picasso;
11 | import java.io.File;
12 | import java.util.List;
13 | import me.wavever.ganklock.R;
14 | import me.wavever.ganklock.event.ClickEvent;
15 | import me.wavever.ganklock.event.RxBus;
16 | import me.wavever.ganklock.ui.adapter.MeizhiRecyclerViewAdapter.MeizhiViewHolder;
17 |
18 | /**
19 | * Created by wavever on 2016/9/27.
20 | */
21 |
22 | public class MeizhiRecyclerViewAdapter extends Adapter {
23 |
24 | private List mList;
25 | private Context mContext;
26 |
27 | public void setList(List list) {
28 | this.mList = list;
29 | }
30 |
31 | public MeizhiRecyclerViewAdapter(Context context){
32 | mContext = context;
33 | }
34 |
35 | @Override
36 | public MeizhiViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
37 | View view = LayoutInflater.from(parent.getContext())
38 | .inflate(R.layout.item_meizhi_recycler_view, parent, false);
39 | return new MeizhiViewHolder(view);
40 | }
41 |
42 | @Override
43 | public void onBindViewHolder(MeizhiViewHolder holder, int position) {
44 | holder.position = position;
45 | Picasso.with(mContext).load(mList.get(position)).resize(300,300).centerCrop().into(holder.img);
46 | }
47 |
48 |
49 | @Override public int getItemCount() {
50 | return mList == null ? 0 : mList.size();
51 | }
52 |
53 |
54 | class MeizhiViewHolder extends ViewHolder {
55 |
56 | ImageView img;
57 | int position;
58 |
59 | public MeizhiViewHolder(View itemView) {
60 | super(itemView);
61 | img = (ImageView) itemView.findViewById(R.id.item_photo);
62 | img.setOnClickListener(new View.OnClickListener() {
63 | @Override public void onClick(View v) {
64 | RxBus.getInstance()
65 | .post(new ClickEvent(ClickEvent.CLICK_TYPE_MEIZHI, position));
66 | }
67 | });
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.fragment;
2 |
3 |
4 | import android.app.Activity;
5 | import android.app.Fragment;
6 | import android.content.Context;
7 | import android.os.Bundle;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import me.wavever.ganklock.presenter.BasePresenter;
12 | import me.wavever.ganklock.presenter.IPresenter;
13 | import rx.Subscription;
14 |
15 | /**
16 | * Created by wavever on 2016/8/12.
17 | */
18 | public abstract class BaseFragment> extends Fragment implements IPresenter {
19 |
20 | protected P mPresenter = null;
21 | protected Activity mContext = null;
22 | protected Subscription mSubscrition = null;
23 |
24 | /**
25 | * 加载xml
26 | * @return xml的id
27 | */
28 | protected abstract int loadView();
29 |
30 | /**
31 | * 初始化View
32 | */
33 | protected abstract void initView();
34 |
35 | @Override
36 | public P getPresenter() {
37 | return mPresenter;
38 | }
39 |
40 |
41 | @Override
42 | public void onAttach(Context context) {
43 | super.onAttach(context);
44 | }
45 |
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 | if (mPresenter != null) {
50 | mPresenter.attachView((V) this);
51 | mPresenter.onFragmentLifeCreate();
52 | }
53 | mContext = getActivity();
54 | }
55 |
56 | @Override
57 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
58 | if (mPresenter == null) {
59 | mPresenter = createPresenter();
60 | if(mPresenter!=null){
61 | mPresenter.attachView((V) this);
62 | }
63 | }
64 | mPresenter.onFragmentLifeCreateView();
65 | return inflater.inflate(loadView(), container, false);
66 | }
67 |
68 | @Override
69 | public void onActivityCreated(Bundle savedInstanceState) {
70 | super.onActivityCreated(savedInstanceState);
71 | if (mPresenter != null) {
72 | mPresenter.onFragmentLifeActivityCreated();
73 | }
74 | initView();
75 | }
76 |
77 |
78 | @Override
79 | public void onStart() {
80 | super.onStart();
81 | if (mPresenter != null) {
82 | mPresenter.onFragmentLifeStart();
83 | }
84 | }
85 |
86 | @Override
87 | public void onResume() {
88 | super.onResume();
89 | if (mPresenter != null) {
90 | mPresenter.onFragmentLifeResume();
91 | }
92 | }
93 |
94 |
95 | @Override
96 | public void onPause() {
97 | super.onPause();
98 | if (mPresenter != null) {
99 | mPresenter.onFragmentLifePause();
100 | }
101 | }
102 |
103 | @Override
104 | public void onStop() {
105 | super.onStop();
106 | if (mPresenter != null) {
107 | mPresenter.onFragmentLifeStop();
108 | }
109 | }
110 |
111 | @Override
112 | public void onDestroyView() {
113 | super.onDestroyView();
114 | }
115 |
116 | @Override
117 | public void onDestroy() {
118 | super.onDestroy();
119 | if (mPresenter != null) {
120 | mPresenter.onFragmentLifeDestory();
121 | }
122 | if(mSubscrition!=null&&mSubscrition.isUnsubscribed()){
123 | mSubscrition.unsubscribe();
124 | }
125 | }
126 |
127 | @Override
128 | public void onDetach() {
129 | super.onDetach();
130 | }
131 |
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/fragment/LikeFragment.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.fragment;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.View;
8 | import android.widget.ProgressBar;
9 | import android.widget.TextView;
10 | import com.activeandroid.query.Select;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | import me.wavever.ganklock.R;
14 | import me.wavever.ganklock.event.ClickEvent;
15 | import me.wavever.ganklock.event.RxBus;
16 | import me.wavever.ganklock.model.bean.Gank;
17 | import me.wavever.ganklock.presenter.LikePresenter;
18 | import me.wavever.ganklock.ui.activity.WebViewActivity;
19 | import me.wavever.ganklock.ui.adapter.LikeRecyclerViewAdapter;
20 | import me.wavever.ganklock.utils.LogUtil;
21 | import me.wavever.ganklock.view.ILikeView;
22 | import rx.functions.Action1;
23 |
24 | /**
25 | * Created by wavever on 2016/8/12.
26 | */
27 | public class LikeFragment extends BaseFragment implements ILikeView {
28 |
29 | private static final String TAG = LikeFragment.class.getSimpleName() + "-->";
30 |
31 | private RecyclerView mRecyclerView;
32 | private LikeRecyclerViewAdapter mAdapter;
33 | private ProgressBar mProgressBar;
34 | private TextView mTips;
35 | private List mList;
36 |
37 | @Override
38 | protected int loadView() {
39 | return R.layout.fragment_like;
40 | }
41 |
42 |
43 | @Override
44 | protected void initView() {
45 | mRecyclerView = (RecyclerView) mContext.findViewById(R.id.recycler_view_like_fragment);
46 | mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
47 | mAdapter = new LikeRecyclerViewAdapter(mContext);
48 | mRecyclerView.setAdapter(mAdapter);
49 | mTips = (TextView) mContext.findViewById(R.id.empty_tip_like_fragment);
50 | mProgressBar = (ProgressBar) mContext.findViewById(R.id.progress_bar_like_fragment);
51 | mProgressBar.setVisibility(View.VISIBLE);
52 | mList = new ArrayList<>();
53 | }
54 |
55 |
56 | @Override public void onActivityCreated(Bundle savedInstanceState) {
57 | super.onActivityCreated(savedInstanceState);
58 | loadLikeData();
59 | LogUtil.d(TAG + "onActivityCreated执行");
60 | mSubscrition = RxBus.getInstance().tObservable(ClickEvent.class).subscribe(
61 | new Action1() {
62 | @Override public void call(ClickEvent clickEvent) {
63 | if(clickEvent.eventType == ClickEvent.CLICK_TYPE_LIKE){
64 | Intent intent = new Intent(mContext, WebViewActivity.class);
65 | intent.putExtra(WebViewActivity.KEY_TITLE, mList.get(clickEvent.position).getDesc());
66 | intent.putExtra(WebViewActivity.KEY_URL, mList.get(clickEvent.position).getUrl());
67 | startActivity(intent);
68 | }
69 | }
70 | });
71 | }
72 |
73 |
74 | public void loadLikeData() {
75 | getPresenter().getLikeList();
76 | }
77 |
78 |
79 | @Override
80 | public LikePresenter createPresenter() {
81 | return new LikePresenter();
82 | }
83 |
84 |
85 | public void showLikeData(List list) {
86 | if(!mList.isEmpty()){
87 | mList.clear();
88 | }
89 | mList = list;
90 | mAdapter.setDataList(list);
91 | mAdapter.notifyDataSetChanged();
92 | mProgressBar.setVisibility(View.GONE);
93 | mTips.setVisibility(View.GONE);
94 | }
95 |
96 |
97 | @Override public void refreshLikeData(List list) {
98 | }
99 |
100 |
101 | public void showEmptyTip() {
102 | mProgressBar.setVisibility(View.GONE);
103 | mTips.setVisibility(View.VISIBLE);
104 | }
105 |
106 |
107 | /**
108 | * 每次状态改变都会调用
109 | */
110 | @Override public void onHiddenChanged(boolean hidden) {
111 | super.onHiddenChanged(hidden);
112 | if (!hidden) {
113 | LogUtil.d(TAG + "onHiddenChanged执行--》展示");
114 | int dbCount = new Select().from(Gank.class).count();
115 | if (mTips.getVisibility() == View.VISIBLE && dbCount > 0) {//此时的Like为空
116 | loadLikeData();
117 | } else {
118 | if (dbCount > mAdapter.getItemCount()) {
119 | loadLikeData();
120 | }
121 | }
122 | } else {
123 | LogUtil.d(TAG + "onHiddenChanged执行--》隐藏");
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/fragment/MeizhiFragment.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.fragment;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.widget.GridLayoutManager;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.View;
7 | import android.widget.ProgressBar;
8 | import android.widget.TextView;
9 | import java.io.File;
10 | import java.util.List;
11 | import me.wavever.ganklock.R;
12 | import me.wavever.ganklock.event.ClickEvent;
13 | import me.wavever.ganklock.event.RxBus;
14 | import me.wavever.ganklock.presenter.MeiZhiPresenter;
15 | import me.wavever.ganklock.ui.activity.PhotoActivity;
16 | import me.wavever.ganklock.ui.adapter.MeizhiRecyclerViewAdapter;
17 | import me.wavever.ganklock.view.IMeiZhiView;
18 | import rx.functions.Action1;
19 |
20 | /**
21 | * Created by wavever on 2016/8/12.
22 | */
23 | public class MeizhiFragment extends BaseFragment
24 | implements IMeiZhiView {
25 |
26 | private static final String TAG = "MeizhiFragment-->";
27 | private static int sClickCount;
28 | private RecyclerView mRecyclerView;
29 | private MeizhiRecyclerViewAdapter mAdapter;
30 | private TextView mEmptyTip;
31 | private ProgressBar mProgressBar;
32 | private List mList;
33 |
34 | @Override
35 | protected int loadView() {
36 | return R.layout.fragment_meizhi;
37 | }
38 |
39 | @Override
40 | protected void initView() {
41 | mRecyclerView = (RecyclerView) mContext.findViewById(R.id.recycler_view_meizhi_fragment);
42 | GridLayoutManager manager = new GridLayoutManager(mContext, 2);
43 | mRecyclerView.setLayoutManager(manager);
44 | mEmptyTip = (TextView) mContext.findViewById(R.id.empty_tip_meizhi_fragment);
45 | mProgressBar = (ProgressBar) mContext.findViewById(R.id.progress_bar_meizhi_fragment);
46 | mAdapter = new MeizhiRecyclerViewAdapter(mContext);
47 | mRecyclerView.setAdapter(mAdapter);
48 | mProgressBar.setVisibility(View.VISIBLE);
49 | getPresenter().loadMeizhi();
50 | mSubscrition = RxBus.getInstance().tObservable(ClickEvent.class).subscribe(
51 | new Action1() {
52 | @Override public void call(ClickEvent clickEvent) {
53 | if (clickEvent.eventType == ClickEvent.CLICK_TYPE_MEIZHI) {
54 | Intent intent = new Intent(mContext, PhotoActivity.class);
55 | intent.putExtra(PhotoActivity.KEY_ACTIVITY_JUMPED,
56 | PhotoActivity.ACTIVITY_JUMPER_FROM_MEIZHI);
57 | intent.putExtra(PhotoActivity.KEY_PHOTO_URL,
58 | mList.get(clickEvent.position));
59 | startActivity(intent);
60 | }
61 | }
62 | });
63 | }
64 |
65 | @Override
66 | public MeiZhiPresenter createPresenter() {
67 | return new MeiZhiPresenter();
68 | }
69 |
70 | @Override public void showMeizhi(List list) {
71 | mProgressBar.setVisibility(View.GONE);
72 | mEmptyTip.setVisibility(View.GONE);
73 | mList = list;
74 | mAdapter.setList(mList);
75 | mAdapter.notifyDataSetChanged();
76 | }
77 |
78 | @Override public void showEmptyView() {
79 | mProgressBar.setVisibility(View.GONE);
80 | mEmptyTip.setVisibility(View.VISIBLE);
81 | }
82 |
83 | @Override public void showErrorView() {
84 | mProgressBar.setVisibility(View.GONE);
85 | mEmptyTip.setText("出问题了");
86 | mEmptyTip.setVisibility(View.VISIBLE);
87 | }
88 |
89 | @Override public void onHiddenChanged(boolean hidden) {
90 | super.onHiddenChanged(hidden);
91 | if (!hidden) {
92 | sClickCount++;
93 | if (sClickCount % 2 == 0) {
94 | getPresenter().loadMeizhi();
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/fragment/MoreFragment.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.fragment;
2 |
3 | import android.app.Activity;
4 | import android.content.ActivityNotFoundException;
5 | import android.content.Intent;
6 | import android.net.Uri;
7 | import android.os.Build.VERSION;
8 | import android.support.v7.widget.SwitchCompat;
9 | import android.support.v7.widget.Toolbar;
10 | import android.view.View;
11 | import android.view.View.OnClickListener;
12 | import android.widget.CompoundButton;
13 | import android.widget.CompoundButton.OnCheckedChangeListener;
14 | import android.widget.TextView;
15 | import android.widget.Toast;
16 | import me.wavever.ganklock.MyApplication;
17 | import me.wavever.ganklock.R;
18 | import me.wavever.ganklock.config.Config;
19 | import me.wavever.ganklock.presenter.MorePresenter;
20 | import me.wavever.ganklock.service.LockService;
21 | import me.wavever.ganklock.ui.activity.AboutActivity;
22 | import me.wavever.ganklock.ui.activity.LicenseActivity;
23 | import me.wavever.ganklock.ui.activity.SettingActivity;
24 | import me.wavever.ganklock.utils.PreferenceUtil;
25 | import me.wavever.ganklock.utils.ToastUtil;
26 | import me.wavever.ganklock.view.IMoreView;
27 |
28 | /**
29 | * Created by wavever on 2016/9/18.
30 | */
31 |
32 | public class MoreFragment extends BaseFragment implements OnClickListener {
33 |
34 | private TextView mTitle;
35 | private SwitchCompat mSwitch;
36 | private TextView mItemLockSetting, mItemStyleSetting, mItemFeedBack, mItemOpenSource,
37 | mItemEvaluate, mItemAbout;
38 | private Toolbar mToolbar;
39 |
40 | @Override protected int loadView() {
41 | return R.layout.fragment_more;
42 | }
43 |
44 |
45 | @Override protected void initView() {
46 | mToolbar = (Toolbar) mContext.findViewById(R.id.toolbar_more_fragment);
47 | mTitle = (TextView) mContext.findViewById(R.id.more_fragment_title);
48 | mItemLockSetting = (TextView) mContext.findViewById(R.id.more_fragment_item_lock_setting);
49 | mItemLockSetting.setOnClickListener(this);
50 | mItemStyleSetting = (TextView) mContext.findViewById(R.id.more_fragment_item_style_setting);
51 | mItemStyleSetting.setOnClickListener(this);
52 | mItemFeedBack = (TextView) mContext.findViewById(R.id.more_fragment_item_feedback);
53 | mItemFeedBack.setOnClickListener(this);
54 | mItemOpenSource = (TextView) mContext.findViewById(R.id.more_fragment_item_open_source);
55 | mItemOpenSource.setOnClickListener(this);
56 | mItemEvaluate = (TextView) mContext.findViewById(R.id.more_fragment_item_evaluate);
57 | mItemEvaluate.setOnClickListener(this);
58 | mItemAbout = (TextView) mContext.findViewById(R.id.more_fragment_item_about);
59 | mItemAbout.setOnClickListener(this);
60 | mSwitch = (SwitchCompat) mContext.findViewById(R.id.more_fragment_switch_button);
61 | mSwitch.setChecked(PreferenceUtil.getBoolean(Config.GANK_LOCK_IS_OPEN));//根据存储的布尔值来判断是否是开启状态
62 | mSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
63 | @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
64 | if (isChecked) {
65 | ToastUtil.showToastShort(mContext, "open锁屏");
66 | PreferenceUtil.putBoolean(Config.GANK_LOCK_IS_OPEN, true);
67 | //LockManager.startLock(true);//立即显示锁屏
68 | MyApplication.getContext().startService(new Intent(MyApplication.getContext(), LockService.class));
69 | } else {
70 | ToastUtil.showToastShort(mContext, "close锁屏");
71 | PreferenceUtil.putBoolean(Config.GANK_LOCK_IS_OPEN, false);
72 | MyApplication.getContext().stopService(new Intent(MyApplication.getContext(), LockService.class));
73 | //LockManager.cancleLock();
74 | }
75 | }
76 | });
77 | }
78 |
79 |
80 | @Override public MorePresenter createPresenter() {
81 | return new MorePresenter();
82 | }
83 |
84 |
85 | @Override public void onClick(View v) {
86 | switch (v.getId()) {
87 | case R.id.more_fragment_item_lock_setting:
88 | startActivity(new Intent(mContext, SettingActivity.class));
89 | break;
90 | case R.id.more_fragment_item_feedback:
91 | break;
92 | case R.id.more_fragment_item_open_source:
93 | startActivity(new Intent(mContext, LicenseActivity.class));
94 | break;
95 | case R.id.more_fragment_item_evaluate:
96 | Uri uri = Uri.parse("market://details?id=" + mContext.getPackageName());
97 | Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
98 | try {
99 | startActivity(goToMarket);
100 | } catch (ActivityNotFoundException e) {
101 | Toast.makeText(mContext, "Couldn't launch the market !", Toast.LENGTH_SHORT).show();
102 | }
103 | break;
104 | case R.id.more_fragment_item_about:
105 | startActivity(new Intent(mContext, AboutActivity.class));
106 | break;
107 | }
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/fragment/SettingFragment.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.preference.Preference;
5 | import android.preference.PreferenceFragment;
6 | import com.activeandroid.query.Delete;
7 | import com.activeandroid.query.Select;
8 | import me.wavever.ganklock.R;
9 | import me.wavever.ganklock.model.bean.GankDaily;
10 | import me.wavever.ganklock.utils.ToastUtil;
11 | import rx.Observable;
12 | import rx.Subscriber;
13 | import rx.Subscription;
14 | import rx.functions.Action1;
15 |
16 | /**
17 | * Created by wavever on 2016/2/23.
18 | */
19 | public class SettingFragment extends PreferenceFragment
20 | implements Preference.OnPreferenceChangeListener,
21 | Preference.OnPreferenceClickListener {
22 |
23 | private Subscription subscription;
24 |
25 | @Override
26 | public void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | addPreferencesFromResource(R.xml.preferences);
29 | findPreference(getString(R.string.key_lock_style)).setOnPreferenceClickListener(this);
30 | findPreference(getString(R.string.key_shake_feed_back)).setOnPreferenceChangeListener(this);
31 | findPreference("key_clear_cache").setOnPreferenceClickListener(this);
32 | }
33 |
34 |
35 | @Override
36 | public boolean onPreferenceChange(Preference preference, Object newValue) {
37 | String key = preference.getKey();
38 | if (key.equals(getString(R.string.key_shake_feed_back))) {
39 | if ((Boolean) newValue) {
40 | } else {
41 | }
42 | }
43 | return true;
44 | }
45 |
46 | @Override
47 | public boolean onPreferenceClick(Preference preference) {
48 | String key = preference.getKey();
49 | if (key.equals(getString(R.string.key_clear_cache))) {
50 | Observable.create(new Observable.OnSubscribe() {
51 | @Override public void call(Subscriber super Integer> subscriber) {
52 | new Delete().from(GankDaily.class).execute();
53 | subscriber.onNext(new Select().from(GankDaily.class).count());
54 | }
55 | }).subscribe(new Action1() {
56 | @Override public void call(Integer count) {
57 | if (count == 0) {
58 | ToastUtil.showToastShort(getActivity(), "清除缓存成功~");
59 | } else {
60 | ToastUtil.showToastShort(getActivity(), "清除缓存失败~");
61 | }
62 | }
63 | });
64 | } else if (key.equals(getString(R.string.key_lock_style))) {
65 | ToastUtil.showToastShort(getActivity(), "正在开发中哦");
66 | }
67 | return false;
68 | }
69 |
70 |
71 | @Override public void onDestroy() {
72 | super.onDestroy();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/widget/RatioImageView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2015 XiNGRZ
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package me.wavever.ganklock.ui.widget;
18 |
19 | import android.content.Context;
20 | import android.util.AttributeSet;
21 | import android.widget.ImageView;
22 |
23 | /**
24 | * 一个能保持比例的 ImageView
25 | * TODO: 暂时只支持维持宽度适应高度
26 | *
27 | * @author XiNGRZ
28 | */
29 | public class RatioImageView extends ImageView {
30 |
31 | private int originalWidth;
32 | private int originalHeight;
33 |
34 | public RatioImageView(Context context) {
35 | super(context);
36 | }
37 |
38 | public RatioImageView(Context context, AttributeSet attrs) {
39 | super(context, attrs);
40 | }
41 |
42 | public RatioImageView(Context context, AttributeSet attrs, int defStyleAttr) {
43 | super(context, attrs, defStyleAttr);
44 | }
45 |
46 | public void setOriginalSize(int originalWidth, int originalHeight) {
47 | this.originalWidth = originalWidth;
48 | this.originalHeight = originalHeight;
49 | }
50 |
51 | @Override
52 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
53 | if (originalWidth > 0 && originalHeight > 0) {
54 | float ratio = (float) originalWidth / (float) originalHeight;
55 |
56 | int width = MeasureSpec.getSize(widthMeasureSpec);
57 | int height = MeasureSpec.getSize(heightMeasureSpec);
58 |
59 | // TODO: 现在只支持固定宽度
60 | if (width > 0) {
61 | height = (int) ((float) width / ratio);
62 | }
63 |
64 | setMeasuredDimension(width, height);
65 | } else {
66 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
67 | }
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/widget/SwipeUnLockLayout.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.widget;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.animation.AnimatorSet;
6 | import android.animation.ObjectAnimator;
7 | import android.content.Context;
8 | import android.util.AttributeSet;
9 | import android.view.MotionEvent;
10 | import android.view.View;
11 | import android.widget.FrameLayout;
12 | import me.wavever.ganklock.R;
13 |
14 | /**
15 | * Created by wavever on 2016/10/11.
16 | */
17 |
18 | public class SwipeUnLockLayout extends FrameLayout {
19 |
20 | private static final int MIN_FLING_VELOCITY = 200;
21 |
22 | //TODO 只能够移动他的直接子View
23 | private View mTimeLayout;
24 | private View mArrow;
25 |
26 | private int mLastInterceptX;
27 |
28 | private float mStartX;
29 | private int mLayoutX;
30 | private int mArrowX;
31 | private float minVel;
32 |
33 | private OnSwipeListener mOnSwipeListener;
34 |
35 | public SwipeUnLockLayout(Context context) {
36 | this(context, null);
37 | }
38 |
39 |
40 | public SwipeUnLockLayout(Context context, AttributeSet attrs) {
41 | this(context, attrs, 0);
42 | }
43 |
44 |
45 | public SwipeUnLockLayout(Context context, AttributeSet attrs, int defStyleAttr) {
46 | super(context, attrs, defStyleAttr);
47 | init(context);
48 | }
49 |
50 |
51 | private void init(Context context) {
52 | final float density = getResources().getDisplayMetrics().density;
53 | minVel = MIN_FLING_VELOCITY * density;
54 | }
55 |
56 |
57 | public void setOnSwipeListener(OnSwipeListener onSwipeListener) {
58 | this.mOnSwipeListener = onSwipeListener;
59 | }
60 |
61 | @Override public boolean onInterceptTouchEvent(MotionEvent ev) {
62 | boolean intercepted = false;
63 | int x = (int) ev.getX();
64 | switch (ev.getAction()){
65 | case MotionEvent.ACTION_DOWN:
66 | mLastInterceptX = x;
67 | intercepted = false;
68 | break;
69 | case MotionEvent.ACTION_MOVE:
70 | if(x==mLastInterceptX){
71 | intercepted = false;
72 | }else {
73 | intercepted = true;
74 | }
75 | break;
76 | case MotionEvent.ACTION_UP:
77 | intercepted = false;
78 | break;
79 | default:
80 | break;
81 | }
82 |
83 | return intercepted;
84 | }
85 |
86 |
87 | @Override public boolean onTouchEvent(MotionEvent event) {
88 |
89 | float x = event.getX();
90 |
91 | switch (event.getAction()){
92 | case MotionEvent.ACTION_DOWN:
93 | mStartX = x;
94 | break;
95 | case MotionEvent.ACTION_MOVE:
96 | float moveX= x - mStartX;
97 | if (moveX < 0)
98 | moveX = 0;
99 | mTimeLayout.setTranslationX(-moveX);
100 | mArrow.setTranslationX(moveX);
101 | break;
102 | case MotionEvent.ACTION_UP:
103 | float moveX1= x - mStartX;
104 | ObjectAnimator animator1;
105 | ObjectAnimator animator2;
106 | AnimatorSet set = new AnimatorSet();
107 | if(moveX1 > minVel){
108 | animator1 = ObjectAnimator.ofFloat(mTimeLayout,"translationX",-200);
109 | animator2 = ObjectAnimator.ofFloat(mArrow,"translationX",-200);
110 | set.setDuration(250).playTogether(animator1,animator2);
111 | set.addListener(new AnimatorListenerAdapter() {
112 | @Override public void onAnimationEnd(Animator animation) {
113 | mOnSwipeListener.onSwipeFinish();
114 | }
115 | });
116 | }else{
117 | animator1 = ObjectAnimator.ofFloat(mTimeLayout,"translationX",mLayoutX);
118 | animator2 = ObjectAnimator.ofFloat(mArrow,"translationX",-mArrowX);
119 | set.setDuration(250).playTogether(animator1,animator2);
120 | }
121 | set.start();
122 | break;
123 | case MotionEvent.ACTION_CANCEL:
124 | break;
125 | }
126 | return true;
127 | }
128 |
129 |
130 | @Override protected void onFinishInflate() {
131 | super.onFinishInflate();
132 | mTimeLayout = findViewById(R.id.lock_view_time_layout);
133 | mArrow = findViewById(R.id.lock_view_arrow);
134 | }
135 |
136 |
137 | @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
138 | super.onLayout(changed, left, top, right, bottom);
139 | //记录初始的位置
140 | mLayoutX = mTimeLayout.getLeft();
141 | mArrowX = mArrow.getLeft();
142 | }
143 |
144 | public interface OnSwipeListener{
145 | void onSwipeFinish();
146 | }
147 |
148 |
149 | }
150 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/widget/UnlockArrow.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | import me.wavever.ganklock.R;
12 |
13 | /**
14 | * Created by wavevr on 2016/2/20.
15 | */
16 | public class UnlockArrow extends View {
17 |
18 | private int width;
19 | private int height;
20 | private int strokeWidth;
21 | private Paint paint;
22 | private Path path;
23 |
24 | public UnlockArrow(Context context) {
25 | this(context, null);
26 | }
27 |
28 | public UnlockArrow(Context context, AttributeSet attrs) {
29 | this(context, attrs, 0);
30 | }
31 |
32 |
33 | public UnlockArrow(Context context, AttributeSet attrs, int defStyleAttr) {
34 | super(context, attrs, defStyleAttr);
35 | init(context);
36 | }
37 |
38 |
39 | private void init(Context context) {
40 | paint = new Paint();
41 | path = new Path();
42 | strokeWidth = context.getResources().getDimensionPixelSize(R.dimen.unlock_arrow_stroke_width);
43 | width = context.getResources().getDimensionPixelSize(R.dimen.unlock_arrow_width);
44 | height = context.getResources().getDimensionPixelSize(R.dimen.unlock_arrow_height);
45 | paint.setStrokeJoin(Paint.Join.ROUND);
46 | paint.setStrokeCap(Paint.Cap.ROUND);
47 | paint.setStrokeWidth((float) this.strokeWidth);
48 | paint.setStyle(Paint.Style.STROKE);
49 | paint.setAntiAlias(true);
50 | paint.setColor(Color.WHITE);
51 | }
52 |
53 | @Override
54 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
55 |
56 | setMeasuredDimension(measureWidth(widthMeasureSpec), measureHeight(heightMeasureSpec));
57 |
58 | }
59 |
60 | private int measureWidth(int widthMeasureSpec) {
61 | int result = 0;
62 | int width = MeasureSpec.getSize(widthMeasureSpec);
63 | int mode = MeasureSpec.getMode(widthMeasureSpec);
64 | if(mode == MeasureSpec.EXACTLY){
65 | result = width;
66 | }else{
67 | if(mode == MeasureSpec.AT_MOST){
68 | result = this.width+strokeWidth;
69 | }
70 | }
71 | return result;
72 | }
73 |
74 | private int measureHeight(int heightMeasureSpec) {
75 | int result = 0;
76 | int height = MeasureSpec.getSize(heightMeasureSpec);
77 | int mode = MeasureSpec.getMode(heightMeasureSpec);
78 | if(mode == MeasureSpec.EXACTLY){
79 | result = height;
80 | }else{
81 | if(mode == MeasureSpec.AT_MOST){
82 | result = this.height+strokeWidth;
83 | }
84 | }
85 | return result;
86 | }
87 |
88 | @Override
89 | protected void onDraw(Canvas canvas) {
90 | super.onDraw(canvas);
91 | path.reset();
92 | path.moveTo(0, 0);
93 | path.lineTo(width, height / 2);
94 | path.lineTo(0, height);
95 | canvas.drawPath(path, paint);
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/ui/widget/UnlockArrowHolder.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.ui.widget;
2 |
3 | import android.animation.AnimatorSet;
4 | import android.animation.FloatEvaluator;
5 | import android.animation.ObjectAnimator;
6 | import android.animation.ValueAnimator;
7 | import android.content.Context;
8 | import android.util.AttributeSet;
9 | import android.view.animation.LinearInterpolator;
10 | import android.widget.RelativeLayout;
11 |
12 | import me.wavever.ganklock.R;
13 |
14 | /**
15 | * Created by wavever on 2016/5/25.
16 | */
17 | public class UnlockArrowHolder extends RelativeLayout {
18 |
19 | private ValueAnimator valueAnimator = null;
20 | private AnimatorSet animationSet = null;
21 | private UnlockArrow[] arrows = null;
22 | private int animationDistance = 0;//滑动箭头做动画的距离
23 | private int arrowGap = 0;//箭头之间的距离
24 |
25 | public UnlockArrowHolder(Context context) {
26 | super(context);
27 | init(context);
28 | }
29 |
30 | public UnlockArrowHolder(Context context, AttributeSet attrs) {
31 | super(context, attrs);
32 | init(context);
33 | }
34 |
35 | public UnlockArrowHolder(Context context, AttributeSet attrs, int defStyleAttr) {
36 | super(context, attrs, defStyleAttr);
37 | init(context);
38 | }
39 |
40 | private void init(Context context) {
41 | animationDistance = (int) context.getResources().getDimension(R.dimen.unlock_arrow_animation_distance);
42 | arrowGap = context.getResources().getDimensionPixelSize(R.dimen.unlock_arrow_gap);
43 | arrows = new UnlockArrow[3];
44 | for (int i = 0; i < 3; i++) {
45 | arrows[i] = new UnlockArrow(getContext());
46 | addView(arrows[i]);
47 | arrows[i].setAlpha(0.0f);
48 | }
49 | animationSet = new AnimatorSet();
50 | animationSet.setInterpolator(new LinearInterpolator());
51 | float f = animationDistance * 2 + arrowGap * 2; //总共的距离
52 | valueAnimator = ObjectAnimator.ofObject(new ArrowEvaluator(this), new Object[]{Integer.valueOf(0), Float.valueOf(f)}).setDuration(1680);
53 | valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
54 | animationSet.play(valueAnimator);
55 | }
56 |
57 | public class ArrowEvaluator extends FloatEvaluator {
58 |
59 | private final UnlockArrowHolder unlockArrowHolder;
60 |
61 | public ArrowEvaluator(UnlockArrowHolder unlockArrowHolder) {
62 | this.unlockArrowHolder = unlockArrowHolder;
63 | }
64 |
65 | @Override
66 | public Float evaluate(float fraction, Number startValue, Number endValue) {
67 |
68 | float startFloat = startValue.floatValue();
69 | float float2 = startFloat + ((endValue.floatValue() - startFloat) * fraction);//当前动画的完成度
70 | for (int i = 0; i < 3; i++) {
71 | float s = float2 - arrowGap * i;
72 | if (s > animationDistance * 2) {
73 | s = animationDistance * 2;
74 | }
75 | arrows[i].setTranslationX(s);
76 | arrows[i].setAlpha(s > animationDistance ?
77 | ((animationDistance * 2 - s) / (animationDistance * 1.0f)) : animationDistance * 1.0f);
78 | }
79 | return Float.valueOf((endValue.floatValue() - startFloat) * fraction + startFloat);
80 | }
81 | }
82 |
83 | @Override
84 | protected void onAttachedToWindow() {
85 | startAnim();
86 | super.onAttachedToWindow();
87 | }
88 |
89 | public void startAnim() {
90 | setVisibility(VISIBLE);
91 | for (int i = 0; i < 3; i++) {
92 | arrows[i].setLayerType(LAYER_TYPE_HARDWARE, null);
93 | }
94 | animationSet.start();
95 | }
96 |
97 | public void stopAnim() {
98 | setVisibility(GONE);
99 | for (int i = 0; i < 3; i++) {
100 | arrows[i].setLayerType(LAYER_TYPE_NONE, null);
101 | }
102 | animationSet.cancel();//set会遍历子Animator调用cancel方法
103 | }
104 |
105 | @Override
106 | protected void onDetachedFromWindow() {
107 | stopAnim();
108 | super.onDetachedFromWindow();
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/utils/DialogUtil.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.utils;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Context;
5 | import android.support.v7.app.AlertDialog;
6 |
7 | import me.wavever.ganklock.R;
8 |
9 | /**
10 | * Created by wavever on 2016/2/22.
11 | */
12 | public class DialogUtil {
13 |
14 | private static ProgressDialog progressDialog;
15 |
16 | public static void showSingleBUttonDialog(Context context, String msg) {
17 | new AlertDialog.Builder(context)
18 | .setCancelable(true)
19 | .setMessage(msg)
20 | .setTitle(R.string.dialog_tip)
21 | .setPositiveButton(R.string.dialog_confirm,null)
22 | .show();
23 | }
24 |
25 | public static void showSingleDialog(Context context, int msgId) {
26 | showSingleBUttonDialog(context,context.getResources().getString(msgId));
27 | }
28 |
29 | public static void showLoadingDialog(Context context){
30 | progressDialog = new ProgressDialog(context);
31 | progressDialog.setMessage("主人别急,正在加载");
32 | progressDialog.show();
33 | }
34 |
35 | public static void dismissLoadingDialog(){
36 | if (progressDialog != null){
37 | progressDialog.dismiss();
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/utils/LogUtil.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.utils;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by WAVE on 2016/2/23.
7 | */
8 | public class LogUtil {
9 |
10 | private static final String TAG = "TAG";
11 |
12 | public static final int VERBOSE = 1;
13 |
14 | public static final int DEBUG = 2;
15 |
16 | public static final int INFO = 3;
17 |
18 | public static final int WRAN = 4;
19 |
20 | public static final int ERROR = 5;
21 |
22 | public static final int NOTHING = 6;
23 |
24 | public static final int LEVEL = VERBOSE;
25 |
26 | //只需要修改LEVEL的值,就可以自由的控制日志的打印,
27 | // 当LEVEL为NOTHING时,就可以屏蔽掉所有的日志
28 |
29 | public static void v(String message) {
30 | if (LEVEL <= VERBOSE) {
31 | Log.v(TAG, message);
32 | }
33 | }
34 |
35 | public static void d(String message) {
36 | if (LEVEL <= DEBUG) {
37 | Log.d(TAG,message);
38 | }
39 | }
40 |
41 | public static void i(String message) {
42 | if (LEVEL <= INFO) {
43 | Log.i(TAG,message);
44 | }
45 | }
46 |
47 | public static void w(String message) {
48 | if (LEVEL <= WRAN) {
49 | Log.w(TAG,message);
50 | }
51 | }
52 |
53 | public static void e(String message) {
54 | if (LEVEL <= ERROR) {
55 | Log.e(TAG,message);
56 | }
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/utils/PreferenceUtil.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.utils;
2 |
3 | import android.content.SharedPreferences;
4 | import android.content.SharedPreferences.Editor;
5 | import android.preference.PreferenceManager;
6 | import me.wavever.ganklock.MyApplication;
7 |
8 | public class PreferenceUtil {
9 | private static SharedPreferences prefs;
10 | private static Editor editor;
11 |
12 |
13 | static {
14 | prefs = PreferenceManager.getDefaultSharedPreferences(MyApplication.getContext());
15 | editor = prefs.edit();
16 | }
17 |
18 |
19 | public static void putString(String key, String value) {
20 | editor.putString(key, value).apply();
21 | }
22 |
23 |
24 | public static String getString(String key) {
25 | return prefs.getString(key, "");
26 | }
27 |
28 |
29 | public static void putInt(String key, int value) {
30 | editor.putInt(key, value).apply();
31 | }
32 |
33 |
34 | public static int getInt(String key,int value) {
35 | return prefs.getInt(key, value);
36 | }
37 |
38 |
39 | public static void putBoolean(String key, boolean value) {
40 | editor.putBoolean(key, value).apply();//apply没有返回值,commit返回值为布尔值
41 | }
42 |
43 | public static boolean getBoolean(String key) {
44 | return prefs.getBoolean(key, false);
45 | }
46 |
47 |
48 | public static boolean clear() {
49 | editor.clear();
50 | return editor.commit();
51 | }
52 |
53 |
54 | public static void close() {
55 | prefs = null;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/utils/StringUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * Copyright (C) 2015 Drakeet
4 | * Copyright (C) 2015 GuDong
5 | *
6 | * Meizhi is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, either version 3 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * Meizhi is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with Meizhi. If not, see .
18 | */
19 |
20 | package me.wavever.ganklock.utils;
21 |
22 | import android.content.Context;
23 | import android.content.pm.ApplicationInfo;
24 | import android.content.pm.PackageManager;
25 | import android.content.res.AssetManager;
26 | import android.graphics.Typeface;
27 | import me.wavever.ganklock.MyApplication;
28 |
29 | public class StringUtil {
30 |
31 | public static AssetManager assetManager = MyApplication.getContext().getAssets();
32 |
33 | public static Typeface getTypeFace(String fontName) {
34 | return Typeface.createFromAsset(MyApplication.getContext().getAssets(),
35 | "fonts/" + fontName);
36 | }
37 |
38 | public static String getChannelValue(){
39 | Context context = MyApplication.getContext();
40 | String value = "";
41 | try {
42 | ApplicationInfo info = context.getPackageManager().getApplicationInfo(context.getPackageName(),
43 | PackageManager.GET_META_DATA);
44 | value = info.metaData.getString("UMENG_CHANNEL");
45 | } catch (PackageManager.NameNotFoundException e) {
46 | e.printStackTrace();
47 | }
48 | return value;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/utils/SystemUtil.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.utils;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 | import me.wavever.ganklock.MyApplication;
7 |
8 | /**
9 | * Created by wavever on 2016/9/20.
10 | */
11 |
12 | public class SystemUtil {
13 |
14 | /**
15 | * 网络是否可用
16 | */
17 | public static boolean isNetworkAvailable() {
18 | ConnectivityManager manager = (ConnectivityManager) MyApplication.getContext()
19 | .getSystemService(Context.CONNECTIVITY_SERVICE);
20 | NetworkInfo info = manager.getActiveNetworkInfo();
21 | if (info != null) {
22 | return info.isAvailable();
23 | }
24 | return false;
25 | }
26 |
27 |
28 | /**
29 | * 获取当前网络状态:WiFi OR Mobile
30 | * @return if wifi return 1 or mobile return 1
31 | */
32 | public static int getNetType() {
33 | ConnectivityManager manager = (ConnectivityManager) MyApplication.getContext()
34 | .getSystemService(Context.CONNECTIVITY_SERVICE);
35 | if (manager != null) {
36 | NetworkInfo info = manager.getActiveNetworkInfo();
37 | if (info != null && info.isConnected()) {
38 | if (info.getState() == NetworkInfo.State.CONNECTED) {
39 | if (info.getType() == ConnectivityManager.TYPE_WIFI) {
40 | return 1;//wifi
41 | } else if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
42 | return 0;//mobile
43 | }
44 | }
45 | }
46 | }
47 | return -1;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/utils/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.utils;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | /**
7 | * Created by wavever on 2016/8/14.
8 | */
9 | public class ToastUtil {
10 |
11 | private static Toast sToast;
12 |
13 | public static void showToastShort(Context context, String content) {
14 | if (sToast == null) {
15 | sToast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
16 | } else {
17 | sToast.setText(content);
18 | }
19 | sToast.show();
20 | }
21 |
22 | public static void showToastLong(Context context, String content) {
23 | if (sToast == null) {
24 | sToast = Toast.makeText(context, content, Toast.LENGTH_LONG);
25 | } else {
26 | sToast.setText(content);
27 | }
28 | sToast.show();
29 | }
30 |
31 | public static void showToastShort(Context context, int resId) {
32 | showToastShort(context, context.getResources().getString(resId));
33 | }
34 |
35 | public static void showToastLong(Context context, int resId) {
36 | showToastLong(context, context.getResources().getString(resId));
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/utils/UIUtil.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.utils;
2 |
3 | import android.content.Context;
4 | import android.util.DisplayMetrics;
5 | import android.util.TypedValue;
6 | import android.view.KeyCharacterMap;
7 | import android.view.KeyEvent;
8 | import android.view.ViewConfiguration;
9 | import android.view.WindowManager;
10 |
11 | import me.wavever.ganklock.MyApplication;
12 |
13 | /**
14 | * Created by wavever on 2016/3/10.
15 | */
16 | public class UIUtil {
17 |
18 | public static int[] getScreenSize() {
19 | DisplayMetrics metrics = new DisplayMetrics();
20 | WindowManager windowManager
21 | = (WindowManager) MyApplication.getContext()
22 | .getSystemService(
23 | Context.WINDOW_SERVICE);
24 | windowManager.getDefaultDisplay().getMetrics(metrics);
25 | return new int[]{metrics.widthPixels, metrics.heightPixels};
26 | }
27 |
28 |
29 | public static int dp2px(int dp, Context context) {
30 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
31 | dp, context.getResources().getDisplayMetrics());
32 | }
33 |
34 | public static int sp2px(int sp,Context context) {
35 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
36 | sp, context.getResources().getDisplayMetrics());
37 | }
38 |
39 | /**
40 | * 获取状态栏高度
41 | *
42 | * @param context
43 | * @return
44 | */
45 | public static int getStatusHeight(Context context) {
46 | int statusHeight = -1;
47 | try {
48 | Class> clazz = Class.forName("com.android.internal.R$dimen");//com.android.internal.R.dimen
49 | Object object = clazz.newInstance();
50 | int height = Integer.parseInt(clazz.getField("status_bar_height").get(object).toString());
51 | statusHeight = context.getResources().getDimensionPixelSize(height);
52 | } catch (Exception e) {
53 | e.printStackTrace();
54 | }
55 | return statusHeight;
56 | }
57 |
58 |
59 |
60 | /**
61 | * 通过是否有物理按键来确定是否有虚拟按键
62 | *
63 | * @return
64 | */
65 | public static boolean isHasNavigationBar(Context context) {
66 | boolean hasMenuKey = ViewConfiguration.get(context).hasPermanentMenuKey();
67 | boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
68 | return !(hasBackKey && hasMenuKey);
69 | }
70 |
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/IBaseView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 |
4 | /**
5 | * Created by WAVE on 2016/3/4.
6 | */
7 | public interface IBaseView{
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/IDailyGankView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 |
4 | import java.util.List;
5 | import me.wavever.ganklock.model.bean.GankDaily;
6 |
7 | /**
8 | * Created by wavever on 2016/8/14.
9 | */
10 | public interface IDailyGankView extends IBaseView{
11 | void showLoading();
12 | void loadDailyData(int page);
13 | void loadFailure();
14 | void loadTodayDailyData();
15 | void showDailyData(List ganks);
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/IGankContentView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 | import java.util.List;
4 | import me.wavever.ganklock.model.bean.Gank;
5 |
6 | /**
7 | * Created by wavever on 2016/2/22.
8 | */
9 | public interface IGankContentView extends IBaseView {
10 |
11 | void loadData(String date);
12 | void showData(List list);
13 | void showError();
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/ILikeView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 | import java.util.List;
4 | import me.wavever.ganklock.model.bean.Gank;
5 |
6 | /**
7 | * Created by wavever on 2016/9/2.
8 | */
9 | public interface ILikeView extends IBaseView{
10 | void showEmptyTip();
11 | void showLikeData(List list);
12 | void refreshLikeData(List list);
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/ILockView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 | public interface ILockView extends IBaseView {
4 | }
5 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/IMeiZhiView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 | import java.io.File;
4 | import java.util.List;
5 |
6 | /**
7 | * Created by wavever on 2016/9/2.
8 | */
9 | public interface IMeiZhiView extends IBaseView{
10 |
11 | void showMeizhi(List list);
12 | void showEmptyView();
13 | void showErrorView();
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/IMoreView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 | /**
4 | * Created by wavever on 2016/9/18.
5 | */
6 |
7 | public interface IMoreView{
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/me/wavever/ganklock/view/IWebView.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock.view;
2 |
3 | /**
4 | * Created by wavever on 2016/10/18.
5 | */
6 |
7 | public interface IWebView extends IBaseView{
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/main/res/color/selector_primary_click.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_settings_white_36dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-hdpi/ic_settings_white_36dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_card_48dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xhdpi/ic_card_48dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_check_white_18dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xhdpi/ic_check_white_18dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_favorite_grey_500_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xhdpi/ic_favorite_grey_500_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_favorite_red_500_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xhdpi/ic_favorite_red_500_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_share_grey_500_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xhdpi/ic_share_grey_500_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/empty_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xxhdpi/empty_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/l_new_tip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xxhdpi/l_new_tip.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/test_image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xxhdpi/test_image.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_cloud_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xxxhdpi/ic_cloud_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_format_list_numbered_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xxxhdpi/ic_format_list_numbered_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_portrait_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xxxhdpi/ic_portrait_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_star_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/drawable-xxxhdpi/ic_star_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_card_nopic.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
21 |
22 |
23 |
24 | -
25 |
26 |
27 |
28 |
29 |
30 |
31 | -
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_more_fragment_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/daily_mask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/lock_date_mask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/more_item_line_divider.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selector_pick_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/toolbar_shadow_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_gank_content.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
14 |
15 |
20 |
21 |
28 |
29 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_lock.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
23 |
24 |
31 |
32 |
38 |
39 |
47 |
48 |
55 |
56 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_photo.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
23 |
24 |
31 |
32 |
39 |
40 |
41 |
42 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_setting.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_daily.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
24 |
25 |
28 |
29 |
36 |
37 |
44 |
45 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_license.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_like.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
24 |
25 |
26 |
29 |
30 |
34 |
35 |
42 |
43 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_meizhi.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
23 |
24 |
25 |
28 |
29 |
34 |
35 |
42 |
43 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_daily_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
24 |
25 |
31 |
32 |
36 |
37 |
42 |
49 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_gank_rv_content.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
30 |
31 |
34 |
45 |
46 |
54 |
55 |
62 |
63 |
64 |
72 |
73 |
81 |
82 |
91 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_like_rv.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
23 |
24 |
29 |
30 |
37 |
38 |
49 |
50 |
61 |
62 |
68 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_meizhi_recycler_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/layout_lock_time.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
16 |
24 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar_shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main_menu.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/navigation.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/mipmap-hdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/mipmap-mdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/mipmap-xhdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/mipmap-xxhdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/app/src/main/res/mipmap-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v19/style.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/android_material_design_colours.xml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | #0091ea
39 |
40 |
41 |
42 |
43 | #00bfa5
44 |
45 |
46 |
47 |
48 |
49 |
50 | #aeea00
51 |
52 |
53 |
54 |
55 | #ffd54f
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | #757575
65 | #424242
66 |
67 |
68 | #90a4ae
69 |
70 |
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FF5252
4 |
5 | #fff
6 | #000
7 |
8 |
9 |
10 |
11 | #838383
12 | #54a9a5a5
13 | #54a9a5a5
14 |
15 |
16 | #009688
17 | #00796b
18 | #9e00796b
19 | #eaeaea
20 |
21 | #999999-
22 |
23 |
24 | #009688
25 | #00796b
26 | #9e00796b
27 |
28 | #fb7299
29 | #b85671
30 | #99f0486c
31 |
32 | #2196F3
33 | #1565C0
34 | #B41A78C3
35 |
36 | #4CAF50
37 | #2E7D32
38 | #994CAF50
39 |
40 | #8BC34A
41 | #558B2F
42 | #998BC34A
43 |
44 | #FDD835
45 | #FBC02D
46 | #99FDD835
47 |
48 | #FF9800
49 | #EF6C00
50 | #99FF9800
51 |
52 | #F44336
53 | #C62828
54 | #99F44336
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 7dp
7 | 13dp
8 | 1.5dp
9 | 18dp
10 | 8dp
11 |
12 |
13 | 6dp
14 | 230dp
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | 200dp
24 | 16dp
25 | 18sp
26 |
27 |
28 | 10dp
29 | 14sp
30 | 18dp
31 | 18dp
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Gank锁屏
3 |
4 |
5 | 可爱的提示
6 | 确认~
7 |
8 |
9 | 设置
10 | 关于
11 | 分享
12 |
13 |
14 | 基本设置
15 | 锁屏设置
16 | 锁屏样式
17 | 摇一摇发送反馈
18 | 发现了Bug?摇一摇就能反馈了哦
19 | 清除缓存
20 | 包括图片、文字缓存
21 |
22 | key_preference_category_lock
23 | key_is_open
24 | key_shake_feed_back
25 | key_clear_cache
26 |
27 | key_lock_style
28 |
29 | 当前版本:
30 |
31 |
32 | 干货集中营拥众多客户端之一,简单实现了一个锁屏界面,更新每天的妹子图片。
33 |
34 | wavever http://wavever.cn\n开源地址 http://github.com/wavever/GankLock
35 | 数据来源 http://gank.io\n所有所使用开源库的作者
36 |
37 |
38 |
39 | 干货
40 | 收藏
41 | 妹纸
42 | 更多
43 |
44 | 发现
45 | 闲读
46 | 广场
47 | 我
48 |
49 |
50 | 嗨呀!好气啊,加载失败了。
51 |
52 | 九月·廿一
53 | 今日力推:Android 漂亮的画廊效果 / Android 着色器和过滤器详解 / Canvas 粒子动画 / iOS 轻量级 Note 开元项目 Dropnote
54 |
55 |
56 | 空空如也~
57 |
58 |
59 | 你不下载妹纸我展示啥
60 |
61 |
62 | 主题
63 | 意见反馈
64 | 开源许可
65 | 去评价
66 | 关于
67 |
68 |
69 | 再按一次退出Gank锁屏
70 |
71 | 我说加载失败了你信么
72 |
73 |
74 | 复制链接
75 | 刷新
76 | 在浏览器中打开
77 | Main2Activity
78 | Home
79 | Dashboard
80 | Notifications
81 |
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
13 |
14 |
18 |
19 |
25 |
26 |
33 |
34 |
41 |
42 |
50 |
51 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/preferences.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
12 |
13 |
14 |
16 |
21 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/test/java/me/wavever/ganklock/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package me.wavever.ganklock;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: "config.gradle"
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.2.1'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | google()
19 | maven { url "https://jitpack.io" }
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | def support_version = "28.0.0"
2 | def constrant_version = "1.1.3"
3 | def retrofit_version = "2.5.0"
4 | def okhttp_version = "3.12.0"
5 |
6 | ext {
7 | android = [compileSdkVersion: 28,
8 | buildToolsVersion: "28.0.1",
9 | applicationId : "me.wavever.ganklock",
10 | minSdkVersion : 17,
11 | targetSdkVersion : 28,
12 | versionCode : 3,
13 | versionName : "1.0.0",
14 | abortOnError : false]
15 |
16 | libraries = [
17 | "appcompat_v7" : "com.android.support:appcompat-v7:${support_version}",
18 | "recyclerView" : "com.android.support:recyclerview-v7:${support_version}",
19 | "cardView" : "com.android.support:cardview-v7:${support_version}",
20 | "design" : "com.android.support:design:${support_version}",
21 | "support_vector_drawable" : "com.android.support:support-vector-drawable:${support_version}",
22 | "constraint_layout" : "com.android.support.constraint:constraint-layout:${constrant_version}",
23 | "gson" : "com.google.code.gson:gson:2.8.5",
24 | "rxJava" : "io.reactivex.rxjava2:rxjava:2.2.4",
25 | "rxAndroid" : "io.reactivex.rxjava2:rxandroid:2.1.0",
26 | "retrofit2" : "com.squareup.retrofit2:retrofit:${retrofit_version}",
27 | "retrofit2_converter_gson" : "com.squareup.retrofit2:converter-gson:${retrofit_version}",
28 | "retrofit2_adapter_rxjava" : "com.squareup.retrofit2:adapter-rxjava:${retrofit_version}",
29 | "okhttp3" : "com.squareup.okhttp3:okhttp:${okhttp_version}",
30 | "okhttp3_logging_interceptor": "com.squareup.okhttp3:logging-interceptor:${okhttp_version}",
31 | "materialPreference" : "com.jenzz:materialpreference:1.3",
32 | "activeAndroid" : "com.michaelpardo:activeandroid:3.1.0-SNAPSHOT",
33 | "photoView" : "com.github.chrisbanes:PhotoView:1.3.0",
34 | "licence_fragment" : "com.artit-k:license-fragment:1.3.0",
35 | "leakcanary_debug" : "com.squareup.leakcanary:leakcanary-android:1.5",
36 | "leakcanary_release" : "com.squareup.leakcanary:leakcanary-android-no-op:1.5",
37 | "bugtags" : "com.bugtags.library:bugtags-lib:latest.integration"]
38 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wavever/GankLock/cf8f53cea137c302d069346efb5744ca29633ba3/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Sep 17 18:32:29 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------