Skip to content

Commit 37e6536

Browse files
author
piclabsstudio
committed
Update Widgets
1 parent e8939b2 commit 37e6536

File tree

21 files changed

+3878
-226
lines changed

21 files changed

+3878
-226
lines changed

app/src/main/java/com/dvinfosys/WidgetsExample/Fragments/ButtonFragment.java

Lines changed: 134 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.dvinfosys.WidgetsExample.Fragments;
22

3+
import android.graphics.Color;
34
import android.os.Bundle;
45
import android.support.annotation.NonNull;
56
import android.support.annotation.Nullable;
@@ -9,15 +10,145 @@
910
import android.view.ViewGroup;
1011

1112
import com.dvinfosys.WidgetsExample.R;
13+
import com.dvinfosys.widgets.Button.RoundButton;
14+
import com.dvinfosys.widgets.Button.RoundButtonHelper;
15+
16+
import java.util.Random;
1217

1318
public class ButtonFragment extends Fragment {
1419

20+
private RoundButton btnStandard, btnDot, btnRound, btnAlpha, btnSuccess, btnFailure, btnBonus;
21+
1522
@Override
16-
public View onCreateView(LayoutInflater inflater, ViewGroup container,
17-
Bundle savedInstanceState) {
23+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
24+
View view = inflater.inflate(R.layout.fragment_button, container, false);
25+
btnStandard = view.findViewById(R.id.btn_standard);
26+
btnDot = view.findViewById(R.id.bt_dot);
27+
btnRound = view.findViewById(R.id.bt_round);
28+
btnAlpha = view.findViewById(R.id.bt_alpha);
29+
btnSuccess = view.findViewById(R.id.bt_success);
30+
btnFailure = view.findViewById(R.id.bt_failure);
31+
btnBonus = view.findViewById(R.id.bt_bonus);
32+
33+
btnStandard.setOnClickListener(new View.OnClickListener() {
34+
@Override
35+
public void onClick(View v) {
36+
btnStandard.startAnimation();
37+
btnStandard.postDelayed(new Runnable() {
38+
@Override
39+
public void run() {
40+
btnStandard.revertAnimation();
41+
}
42+
}, 3000);
43+
}
44+
});
45+
46+
btnDot.setOnClickListener(new View.OnClickListener() {
47+
@Override
48+
public void onClick(View v) {
49+
btnDot.startAnimation();
50+
btnDot.postDelayed(new Runnable() {
51+
@Override
52+
public void run() {
53+
btnDot.revertAnimation();
54+
}
55+
}, 3000);
56+
}
57+
});
58+
59+
btnRound.setOnClickListener(new View.OnClickListener() {
60+
@Override
61+
public void onClick(View v) {
62+
btnRound.startAnimation();
63+
btnRound.postDelayed(new Runnable() {
64+
@Override
65+
public void run() {
66+
btnRound.revertAnimation();
67+
}
68+
}, 3000);
69+
}
70+
});
1871

19-
return inflater.inflate(R.layout.fragment_button, container, false);
72+
btnAlpha.setOnClickListener(new View.OnClickListener() {
73+
@Override
74+
public void onClick(View v) {
75+
if (btnAlpha.isAnimating()) {
76+
btnAlpha.setResultState(RoundButton.ResultState.FAILURE);
77+
} else {
78+
btnAlpha.startAnimation();
79+
btnAlpha.postDelayed(new Runnable() {
80+
@Override
81+
public void run() {
82+
btnAlpha.revertAnimation();
83+
}
84+
}, 3000);
85+
}
86+
}
87+
});
88+
89+
btnSuccess.setOnClickListener(new View.OnClickListener() {
90+
@Override
91+
public void onClick(View v) {
92+
btnSuccess.startAnimation();
93+
btnSuccess.postDelayed(new Runnable() {
94+
@Override
95+
public void run() {
96+
btnSuccess.setResultState(RoundButton.ResultState.SUCCESS);
97+
}
98+
}, 3000);
99+
btnSuccess.postDelayed(new Runnable() {
100+
@Override
101+
public void run() {
102+
btnSuccess.revertAnimation();
103+
}
104+
}, 7000);
105+
}
106+
});
107+
108+
btnFailure.setOnClickListener(new View.OnClickListener() {
109+
@Override
110+
public void onClick(View v) {
111+
btnFailure.startAnimation();
112+
btnFailure.postDelayed(new Runnable() {
113+
@Override
114+
public void run() {
115+
btnFailure.setResultState(RoundButton.ResultState.FAILURE);
116+
}
117+
}, 3000);
118+
btnFailure.postDelayed(new Runnable() {
119+
@Override
120+
public void run() {
121+
btnFailure.revertAnimation();
122+
}
123+
}, 7000);
124+
}
125+
});
126+
127+
btnBonus.setOnClickListener(new View.OnClickListener() {
128+
@Override
129+
public void onClick(View v) {
130+
btnBonus.startAnimation();
131+
btnBonus.postDelayed(new Runnable() {
132+
@Override
133+
public void run() {
134+
Random random = new Random();
135+
RoundButtonHelper.Builder builder = RoundButton.newBuilder()
136+
.withText("Bonus")
137+
.withBackgroundColor(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255)))
138+
.withTextColor(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255)))
139+
.withCornerColor(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255)))
140+
.withCornerRadius(random.nextInt(20))
141+
.withCornerWidth(random.nextInt(20));
142+
btnBonus.setCustomizations(builder);
143+
btnBonus.revertAnimation();
144+
}
145+
}, 3000);
146+
}
147+
});
148+
149+
return view;
20150
}
151+
21152
@Override
22153
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
23154
super.onViewCreated(view, savedInstanceState);

app/src/main/java/com/dvinfosys/WidgetsExample/Fragments/EditTextFragment.java

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,51 @@
44
import android.support.annotation.NonNull;
55
import android.support.annotation.Nullable;
66
import android.support.v4.app.Fragment;
7+
import android.text.InputType;
78
import android.view.LayoutInflater;
89
import android.view.View;
910
import android.view.ViewGroup;
11+
import android.view.inputmethod.InputMethodManager;
1012

1113
import com.dvinfosys.WidgetsExample.R;
14+
import com.dvinfosys.widgets.EditText.ZoomEditTextView;
15+
16+
import static android.content.Context.INPUT_METHOD_SERVICE;
1217

1318
public class EditTextFragment extends Fragment {
1419

20+
private ZoomEditTextView edtZoom;
21+
1522
@Override
16-
public View onCreateView(LayoutInflater inflater, ViewGroup container,
17-
Bundle savedInstanceState) {
18-
// Inflate the layout for this fragment
19-
return inflater.inflate(R.layout.fragment_edit_text, container, false);
23+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
24+
View view = inflater.inflate(R.layout.fragment_edit_text, container, false);
25+
edtZoom = view.findViewById(R.id.edt_zoom_edittext);
26+
edtZoom.setOnFocusChangeListener(new MyFocusChangeListener());
27+
edtZoom.setFocusableInTouchMode(true);
28+
edtZoom.setTextIsSelectable(true);
29+
edtZoom.setRawInputType(InputType.TYPE_CLASS_TEXT);
30+
return view;
2031
}
32+
2133
@Override
2234
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
2335
super.onViewCreated(view, savedInstanceState);
24-
getActivity().setTitle("EditText");
36+
getActivity().setTitle("EditText Example");
37+
}
38+
39+
private class MyFocusChangeListener implements View.OnFocusChangeListener {
40+
41+
@Override
42+
public void onFocusChange(View v, boolean hasFocus) {
43+
if (!hasFocus) {
44+
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
45+
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
46+
}
47+
if (hasFocus) {
48+
InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
49+
v.requestFocus();
50+
inputMethodManager.showSoftInput(v, 0);
51+
}
52+
}
2553
}
2654
}

app/src/main/java/com/dvinfosys/WidgetsExample/Fragments/TextViewFragment.java

Lines changed: 135 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.dvinfosys.WidgetsExample.Fragments;
22

3+
import android.graphics.Color;
34
import android.os.Bundle;
45
import android.support.annotation.NonNull;
56
import android.support.annotation.Nullable;
@@ -9,14 +10,144 @@
910
import android.view.ViewGroup;
1011

1112
import com.dvinfosys.WidgetsExample.R;
13+
import com.dvinfosys.widgets.TextView.RoundTextView;
14+
import com.dvinfosys.widgets.TextView.RoundTextViewHelper;
15+
16+
import java.util.Random;
1217

1318
public class TextViewFragment extends Fragment {
1419

20+
private RoundTextView tvStandard, tvDot, tvRound, tvAlpha, tvSuccess, tvFailure, tvBonus;
21+
1522
@Override
16-
public View onCreateView(LayoutInflater inflater, ViewGroup container,
17-
Bundle savedInstanceState) {
18-
// Inflate the layout for this fragment
19-
return inflater.inflate(R.layout.fragment_text_view, container, false);
23+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
24+
View view = inflater.inflate(R.layout.fragment_text_view, container, false);
25+
26+
tvStandard = view.findViewById(R.id.tv_standard);
27+
tvDot = view.findViewById(R.id.tv_dot);
28+
tvRound = view.findViewById(R.id.tv_round);
29+
tvAlpha = view.findViewById(R.id.tv_alpha);
30+
tvSuccess = view.findViewById(R.id.tv_success);
31+
tvFailure = view.findViewById(R.id.tv_failure);
32+
tvBonus = view.findViewById(R.id.tv_bonus);
33+
34+
tvStandard.setOnClickListener(new View.OnClickListener() {
35+
@Override
36+
public void onClick(View v) {
37+
tvStandard.startAnimation();
38+
tvStandard.postDelayed(new Runnable() {
39+
@Override
40+
public void run() {
41+
tvStandard.revertAnimation();
42+
}
43+
}, 3000);
44+
}
45+
});
46+
47+
tvDot.setOnClickListener(new View.OnClickListener() {
48+
@Override
49+
public void onClick(View v) {
50+
tvDot.startAnimation();
51+
tvDot.postDelayed(new Runnable() {
52+
@Override
53+
public void run() {
54+
tvDot.revertAnimation();
55+
}
56+
}, 3000);
57+
}
58+
});
59+
60+
tvRound.setOnClickListener(new View.OnClickListener() {
61+
@Override
62+
public void onClick(View v) {
63+
tvRound.startAnimation();
64+
tvRound.postDelayed(new Runnable() {
65+
@Override
66+
public void run() {
67+
tvRound.revertAnimation();
68+
}
69+
}, 3000);
70+
}
71+
});
72+
73+
tvAlpha.setOnClickListener(new View.OnClickListener() {
74+
@Override
75+
public void onClick(View v) {
76+
if (tvAlpha.isAnimating()) {
77+
tvAlpha.setResultState(RoundTextView.ResultState.FAILURE);
78+
} else {
79+
tvAlpha.startAnimation();
80+
tvAlpha.postDelayed(new Runnable() {
81+
@Override
82+
public void run() {
83+
tvAlpha.revertAnimation();
84+
}
85+
}, 3000);
86+
}
87+
}
88+
});
89+
90+
tvSuccess.setOnClickListener(new View.OnClickListener() {
91+
@Override
92+
public void onClick(View v) {
93+
tvSuccess.startAnimation();
94+
tvSuccess.postDelayed(new Runnable() {
95+
@Override
96+
public void run() {
97+
tvSuccess.setResultState(RoundTextView.ResultState.SUCCESS);
98+
}
99+
}, 3000);
100+
tvSuccess.postDelayed(new Runnable() {
101+
@Override
102+
public void run() {
103+
tvSuccess.revertAnimation();
104+
}
105+
}, 7000);
106+
}
107+
});
108+
109+
tvFailure.setOnClickListener(new View.OnClickListener() {
110+
@Override
111+
public void onClick(View v) {
112+
tvFailure.startAnimation();
113+
tvFailure.postDelayed(new Runnable() {
114+
@Override
115+
public void run() {
116+
tvFailure.setResultState(RoundTextView.ResultState.FAILURE);
117+
}
118+
}, 3000);
119+
tvFailure.postDelayed(new Runnable() {
120+
@Override
121+
public void run() {
122+
tvFailure.revertAnimation();
123+
}
124+
}, 7000);
125+
}
126+
});
127+
128+
tvBonus.setOnClickListener(new View.OnClickListener() {
129+
@Override
130+
public void onClick(View v) {
131+
tvBonus.startAnimation();
132+
tvBonus.postDelayed(new Runnable() {
133+
@Override
134+
public void run() {
135+
Random random = new Random();
136+
RoundTextViewHelper.Builder builder = RoundTextView.newBuilder()
137+
.withText("Bonus")
138+
.withBackgroundColor(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255)))
139+
.withTextColor(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255)))
140+
.withCornerColor(Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255)))
141+
.withCornerRadius(random.nextInt(20))
142+
.withCornerWidth(random.nextInt(20));
143+
tvBonus.setCustomizations(builder);
144+
tvBonus.revertAnimation();
145+
}
146+
}, 3000);
147+
}
148+
});
149+
150+
return view;
20151
}
21152

22153
@Override
230 Bytes
Loading
308 Bytes
Loading

0 commit comments

Comments
 (0)