-
Notifications
You must be signed in to change notification settings - Fork 167
Expand file tree
/
Copy pathMainActivity.java
More file actions
137 lines (105 loc) · 4.6 KB
/
MainActivity.java
File metadata and controls
137 lines (105 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package com.sdsmdg.harjot.rotatingtextlibrary;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import com.sdsmdg.harjot.rotatingtext.RotatingTextSwitcher;
import com.sdsmdg.harjot.rotatingtext.RotatingTextWrapper;
import com.sdsmdg.harjot.rotatingtext.models.Rotatable;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
RotatingTextWrapper rotatingTextWrapper;
RotatingTextSwitcher rotatingTextSwitcher;
Rotatable rotatable, rotatable2;
Spinner s1;
String word;
int nCycles;
EditText enterCycles,e1;
Button button;
Integer[] color = new Integer[]{Color.BLUE,Color.MAGENTA,Color.RED};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rotatingTextSwitcher = new RotatingTextSwitcher(this);
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Raleway-Light.ttf");
Typeface typeface2 = Typeface.createFromAsset(getAssets(), "fonts/Reckoner_Bold.ttf");
rotatingTextWrapper = findViewById(R.id.custom_switcher);
rotatingTextWrapper.setSize(30);
rotatingTextWrapper.setTypeface(typeface2);
// rotatable = new Rotatable(Color.parseColor("#FFA036"), 1000, "Word00", "Word01", "Word02");
rotatable = new Rotatable(color , 1000, "rotating", "text", "library");
rotatable.setSize(25);
rotatable.setTypeface(typeface);
rotatable.setInterpolator(new AccelerateInterpolator());
rotatable.setAnimationDuration(500);
rotatable2 = new Rotatable(Color.parseColor("#123456"), 1000, "word", "word01", "word02");
rotatable2.setSize(25);
rotatable2.setTypeface(typeface);
rotatable2.setInterpolator(new DecelerateInterpolator());
rotatable2.setAnimationDuration(500);
word = rotatable.getTextAt(0);
rotatingTextWrapper.setContent("?abc ? abc", rotatable, rotatable2);
// rotatingTextWrapper.setContent("? abc", rotatable);
s1 = findViewById(R.id.spinner);
List<Integer> list = new ArrayList<Integer>();
list.add(1);
list.add(2);
list.add(3);
ArrayAdapter<Integer> dataAdapter = new ArrayAdapter<Integer>(this,
android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(dataAdapter);
s1.setSelection(0);
e1 = findViewById(R.id.addWord);
button = findViewById(R.id.pause_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!rotatingTextWrapper.getSwitcherList().get(0).isPaused()) {
rotatingTextWrapper.pause(0);
} else {
rotatingTextWrapper.resume(0);
}
}
});
Button buttonChange = findViewById(R.id.change);
buttonChange.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean apply = rotatable.getApplyHorizontal();
rotatable.setApplyHorizontal(!apply);
rotatable2.setApplyHorizontal(!apply);
}
});
}
public void addNewWord(View view) {
String newWord = e1.getText().toString();
if (TextUtils.isEmpty(newWord)) e1.setText("can't be left empty");
else if (newWord.contains("\n")) e1.setText("one line only");
else {
rotatingTextWrapper.setAdaptable(true);
rotatingTextWrapper.addWord(0, (int) s1.getSelectedItem() - 1, newWord);
}
}
public void stopRotation(View view){
enterCycles = findViewById(R.id.enterCycles);
if(!enterCycles.getText().toString().equals("") && enterCycles.getText() != null) {
nCycles = Integer.parseInt(enterCycles.getText().toString());
}
rotatable.setInitialWord(word);
rotatable.setCycles(nCycles);
if (rotatingTextWrapper.getSwitcherList().get(0).isPaused()) {
rotatingTextWrapper.resume(0);
}
}
}