Skip to content

Commit 3ce0fbe

Browse files
committed
check style
1 parent a7f5f0a commit 3ce0fbe

File tree

20 files changed

+128
-206
lines changed

20 files changed

+128
-206
lines changed

app/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ android {
2020

2121
dependencies {
2222
implementation fileTree(include: ['*.jar'], dir: 'libs')
23-
testImplementation 'junit:junit:4.12'
2423
implementation 'androidx.appcompat:appcompat:1.2.0'
2524
implementation 'com.google.android.material:material:1.3.0'
2625
implementation project(':library')

app/src/androidTest/java/com/cpacm/simpleslider/ApplicationTest.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
<uses-permission android:name="android.permission.INTERNET" />
66
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
7-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
87

98
<application
10-
android:allowBackup="true"
119
android:icon="@mipmap/ic_launcher"
1210
android:label="@string/app_name"
1311
android:supportsRtl="true"

app/src/main/java/com/cpacm/simpleslider/BasicActivity.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
1+
/*
2+
* Copyright (C) 2020 cpacm
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+
117
package com.cpacm.simpleslider;
218

319
import android.os.Bundle;
4-
import android.os.Handler;
20+
521
import androidx.appcompat.app.AppCompatActivity;
622
import androidx.appcompat.widget.Toolbar;
23+
724
import android.view.MenuItem;
825
import android.view.animation.Interpolator;
926

1027
import com.cpacm.library.SimpleViewPager;
1128
import com.cpacm.library.transformers.CyclePageTransformer;
1229

13-
import com.cpacm.library.indicator.ViewpagerIndicator.CirclePageIndicator;
1430

1531
public class BasicActivity extends AppCompatActivity {
1632
private final static int DEFAULT_SCROLL_DURATION = 500;
1733

1834

1935
SimpleViewPager simpleSlider, simpleSlider2;
20-
private BasicPagerAdapter adapter,adapter2;
2136

2237
@Override
2338
protected void onCreate(Bundle savedInstanceState) {
2439
super.onCreate(savedInstanceState);
2540
setContentView(R.layout.activity_basic);
26-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
41+
Toolbar toolbar = findViewById(R.id.toolbar);
2742
setSupportActionBar(toolbar);
2843
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
2944

30-
adapter = new BasicPagerAdapter(this);
31-
simpleSlider = (SimpleViewPager) findViewById(R.id.simple_slider);
45+
BasicPagerAdapter adapter = new BasicPagerAdapter(this);
46+
simpleSlider = findViewById(R.id.simple_slider);
3247
simpleSlider.setAdapter(adapter);
3348
simpleSlider.startAutoScroll(true);
3449
simpleSlider.setSliderTransformDuration(DEFAULT_SCROLL_DURATION, new SpringInterpolator());
3550

36-
adapter2 = new BasicPagerAdapter(this);
37-
simpleSlider2 = (SimpleViewPager) findViewById(R.id.simple_slider2);
51+
BasicPagerAdapter adapter2 = new BasicPagerAdapter(this);
52+
simpleSlider2 = findViewById(R.id.simple_slider2);
3853
simpleSlider2.setAdapter(adapter2);
3954
simpleSlider2.startAutoScroll(true);
4055
simpleSlider2.setPageTransformer(new CyclePageTransformer(simpleSlider2));//翻页动画*/
@@ -54,7 +69,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
5469
}
5570

5671
//spring interpolator
57-
private final class SpringInterpolator implements Interpolator {
72+
private static final class SpringInterpolator implements Interpolator {
5873

5974
private final static float FACTOR = 0.5F;
6075

app/src/main/java/com/cpacm/simpleslider/BasicPagerAdapter.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
/*
2+
* Copyright (C) 2020 cpacm
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+
117
package com.cpacm.simpleslider;
218

319
import android.content.Context;
20+
421
import androidx.annotation.NonNull;
522
import androidx.annotation.Nullable;
623
import androidx.viewpager.widget.PagerAdapter;
24+
725
import android.view.LayoutInflater;
826
import android.view.View;
927
import android.view.ViewGroup;
@@ -20,15 +38,15 @@
2038
*/
2139
public class BasicPagerAdapter extends PagerAdapter {
2240

23-
private List<Integer> covers;
24-
private LayoutInflater layoutInflater;
41+
private final List<Integer> covers;
42+
private final LayoutInflater layoutInflater;
2543

2644
public BasicPagerAdapter(Context context) {
2745
covers = getBannerList();
2846
layoutInflater = LayoutInflater.from(context);
2947
}
3048

31-
public void setCovers(){
49+
public void setCovers() {
3250
covers.clear();
3351
covers.add(R.drawable.cover00);
3452
covers.add(R.drawable.cover01);

app/src/main/java/com/cpacm/simpleslider/IndicatorActivity.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2016 cpacm
2+
* Copyright (C) 2020 cpacm
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,8 +17,11 @@
1717
package com.cpacm.simpleslider;
1818

1919
import androidx.appcompat.app.AppCompatActivity;
20+
2021
import android.os.Bundle;
22+
2123
import androidx.appcompat.widget.Toolbar;
24+
2225
import android.view.Menu;
2326
import android.view.MenuItem;
2427

@@ -33,13 +36,6 @@
3336

3437
public class IndicatorActivity extends AppCompatActivity {
3538

36-
private SimpleViewPager simpleSliderLayout;
37-
private CirclePageIndicator circlePageIndicator;
38-
private IconPageIndicator iconPageIndicator;
39-
private LinePageIndicator linePageIndicator;
40-
private UnderlinePageIndicator underlinePageIndicator;
41-
private SpringIndicator springIndicator;
42-
4339
private static final int[] ICONS = new int[]{
4440
R.drawable.perm_group_calendar,
4541
R.drawable.perm_group_camera,
@@ -51,28 +47,28 @@ public class IndicatorActivity extends AppCompatActivity {
5147
protected void onCreate(Bundle savedInstanceState) {
5248
super.onCreate(savedInstanceState);
5349
setContentView(R.layout.activity_indicator);
54-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
50+
Toolbar toolbar = findViewById(R.id.toolbar);
5551
setSupportActionBar(toolbar);
5652
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
5753

58-
simpleSliderLayout = (SimpleViewPager) findViewById(R.id.simple_slider);
54+
SimpleViewPager simpleSliderLayout = findViewById(R.id.simple_slider);
5955
simpleSliderLayout.setAdapter(new BasicPagerAdapter(this));
6056
simpleSliderLayout.setPageTransformer(new ZoomOutSlideTransformer());//翻页动画
6157

62-
circlePageIndicator = (CirclePageIndicator) findViewById(R.id.circle_indicator);
58+
CirclePageIndicator circlePageIndicator = findViewById(R.id.circle_indicator);
6359
circlePageIndicator.setViewPager(simpleSliderLayout);
6460

65-
iconPageIndicator = (IconPageIndicator) findViewById(R.id.icon_indicator);
61+
IconPageIndicator iconPageIndicator = findViewById(R.id.icon_indicator);
6662
iconPageIndicator.setIconRes(ICONS);
6763
iconPageIndicator.setViewPager(simpleSliderLayout);
6864

69-
linePageIndicator = (LinePageIndicator) findViewById(R.id.line_indicator);
65+
LinePageIndicator linePageIndicator = findViewById(R.id.line_indicator);
7066
linePageIndicator.setViewPager(simpleSliderLayout);
7167

72-
underlinePageIndicator = (UnderlinePageIndicator) findViewById(R.id.underline_indicator);
68+
UnderlinePageIndicator underlinePageIndicator = findViewById(R.id.underline_indicator);
7369
underlinePageIndicator.setViewPager(simpleSliderLayout);
7470

75-
springIndicator = (SpringIndicator) findViewById(R.id.spring_indicator);
71+
SpringIndicator springIndicator = findViewById(R.id.spring_indicator);
7672
springIndicator.setViewPager(simpleSliderLayout);
7773
}
7874

app/src/main/java/com/cpacm/simpleslider/TransformActivity.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616

1717
package com.cpacm.simpleslider;
1818

19+
import androidx.annotation.NonNull;
1920
import androidx.appcompat.app.AppCompatActivity;
21+
2022
import android.os.Bundle;
23+
2124
import androidx.recyclerview.widget.LinearLayoutManager;
2225
import androidx.recyclerview.widget.RecyclerView;
2326
import androidx.appcompat.widget.Toolbar;
27+
2428
import android.view.LayoutInflater;
25-
import android.view.Menu;
2629
import android.view.MenuItem;
2730
import android.view.View;
2831
import android.view.ViewGroup;
@@ -56,26 +59,24 @@
5659
public class TransformActivity extends AppCompatActivity {
5760

5861
private SimpleViewPager simpleViewPager;
59-
private RecyclerView transformList;
6062
private List<BaseTransformer> transformers;
6163
private List<String> transformerNames;
62-
private TransformAdapter transformAdapter;
6364

6465
@Override
6566
protected void onCreate(Bundle savedInstanceState) {
6667
super.onCreate(savedInstanceState);
6768
setContentView(R.layout.activity_transform);
68-
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
69+
Toolbar toolbar = findViewById(R.id.toolbar);
6970
setSupportActionBar(toolbar);
7071
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
71-
simpleViewPager = (SimpleViewPager) findViewById(R.id.simple_slider);
72+
simpleViewPager = findViewById(R.id.simple_slider);
7273
simpleViewPager.startAutoScroll(true);
7374

7475
initTransforms();
7576

76-
transformList = (RecyclerView) findViewById(R.id.transform_list);
77+
RecyclerView transformList = findViewById(R.id.transform_list);
7778
transformList.setLayoutManager(new LinearLayoutManager(this));
78-
transformAdapter = new TransformAdapter();
79+
TransformAdapter transformAdapter = new TransformAdapter();
7980
transformList.setAdapter(transformAdapter);
8081

8182
simpleViewPager.setAdapter(new BasicPagerAdapter(this));
@@ -98,8 +99,9 @@ public class TransformAdapter extends RecyclerView.Adapter<TransformAdapter.Norm
9899

99100
private int selectIndex = -1;
100101

102+
@NonNull
101103
@Override
102-
public NormalTextViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
104+
public NormalTextViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
103105
return new NormalTextViewHolder(LayoutInflater.from(TransformActivity.this).inflate(R.layout.list_item, parent, false));
104106
}
105107

-4.06 KB
Binary file not shown.
-146 KB
Binary file not shown.

app/src/test/java/com/cpacm/simpleslider/ExampleUnitTest.java

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)