Reformat
This commit is contained in:
parent
7b6bbc4410
commit
1da5250b9a
6 changed files with 38 additions and 55 deletions
|
@ -29,7 +29,7 @@ fun Kaculate(src: String,ctx :Context) : String{
|
|||
opStack += src[i]
|
||||
}
|
||||
else{
|
||||
ToastHelper.ShowToast("Unknown input char:" + src[i].toString(),ctx);
|
||||
ToastHelper.ShowToast("Unknown input char:" + src[i].toString(),ctx)
|
||||
return src
|
||||
}
|
||||
}
|
||||
|
@ -112,16 +112,3 @@ private fun dropAtIdx(array: FloatArray, idx:Int): FloatArray{
|
|||
}
|
||||
return newArray
|
||||
}
|
||||
private fun dropAtIdx(array: CharArray, idx:Int): CharArray{
|
||||
if (idx>array.size){
|
||||
throw IndexOutOfBoundsException()
|
||||
}
|
||||
|
||||
var newArray = charArrayOf()
|
||||
for (i in array.indices){
|
||||
if (i!=idx){
|
||||
newArray += array[i]
|
||||
}
|
||||
}
|
||||
return newArray
|
||||
}
|
|
@ -39,9 +39,15 @@ public class MainActivity extends AppCompatActivity {
|
|||
textViewAppendString(tv,"Starting Initialize");
|
||||
if (Build.VERSION.SDK_INT >= 33) {
|
||||
textViewAppendString(tv,"Find api > 33, checking permission");
|
||||
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
if (ContextCompat
|
||||
.checkSelfPermission
|
||||
(MainActivity.this, Manifest.permission.POST_NOTIFICATIONS)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
textViewAppendString(tv,"Acquiring POST_NOTIFICATIONS");
|
||||
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, 101);
|
||||
ActivityCompat.requestPermissions
|
||||
(MainActivity.this,
|
||||
new String[]{Manifest.permission.POST_NOTIFICATIONS},
|
||||
101);
|
||||
}
|
||||
textViewAppendString(tv,"Check Finished");
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ public class MainActivity2 extends AppCompatActivity {
|
|||
protected void onResume(){
|
||||
super.onResume();
|
||||
Button button = findViewById(R.id.next_page_nav_2);
|
||||
button.setOnClickListener(new PageButtonHandler());
|
||||
button.setOnLongClickListener(new LongClickHandler());
|
||||
button.setOnClickListener(pageHelper.pageButtonHandler);
|
||||
button.setOnLongClickListener(pageHelper.longClickHandler);
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,7 +88,8 @@ public class MainActivity2 extends AppCompatActivity {
|
|||
if (_r>=0&&_g>=0&&_b>=0&&_r<=255&&_g<=255&&_b<=255){
|
||||
t.setTextColor(Color.rgb(_r,_g,_b));
|
||||
}else{
|
||||
ToastHelper.SmartToast.ShowToast("The color: R="+_r+" G="+_g+" B="+_b+" is invalid!",this);
|
||||
ToastHelper.SmartToast.ShowToast(
|
||||
"The color: R="+_r+" G="+_g+" B="+_b+" is invalid!",this);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -125,22 +126,6 @@ public class MainActivity2 extends AppCompatActivity {
|
|||
px.setText(size +"PX");
|
||||
}
|
||||
|
||||
final class PageButtonHandler implements View.OnClickListener
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
pageHelper.goNext();
|
||||
}
|
||||
}
|
||||
|
||||
final class LongClickHandler implements View.OnLongClickListener
|
||||
{
|
||||
@Override
|
||||
public boolean onLongClick(View v){
|
||||
pageHelper.goPrev();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Fix: hide keyboard
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,8 @@ import androidx.core.graphics.Insets;
|
|||
import androidx.core.view.ViewCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Page3 extends AppCompatActivity {
|
||||
|
||||
PageHelper pageHelper;
|
||||
|
@ -53,8 +55,8 @@ public class Page3 extends AppCompatActivity {
|
|||
|
||||
findViewById(R.id.P3EqualButton).setOnClickListener(new CalculateOnClickListener());
|
||||
|
||||
findViewById(R.id.P3Nextpage).setOnClickListener(new PageButtonHandler());
|
||||
findViewById(R.id.P3Nextpage).setOnLongClickListener(new LongClickHandler());
|
||||
findViewById(R.id.P3Nextpage).setOnClickListener(pageHelper.pageButtonHandler);
|
||||
findViewById(R.id.P3Nextpage).setOnLongClickListener(pageHelper.longClickHandler);
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,22 +162,4 @@ public class Page3 extends AppCompatActivity {
|
|||
|
||||
textView.setText(result);
|
||||
}
|
||||
|
||||
final class PageButtonHandler implements View.OnClickListener
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
pageHelper.goNext();
|
||||
}
|
||||
}
|
||||
|
||||
final class LongClickHandler implements View.OnLongClickListener
|
||||
{
|
||||
@Override
|
||||
public boolean onLongClick(View v){
|
||||
pageHelper.goPrev();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import androidx.core.view.WindowInsetsCompat;
|
|||
|
||||
public class Page4 extends AppCompatActivity {
|
||||
|
||||
PageHelper pageHelper;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
|
|
@ -4,11 +4,16 @@ import static androidx.core.content.ContextCompat.startActivity;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
|
||||
public class PageHelper {
|
||||
private final Context _curr;
|
||||
private final Class<?> _prev;
|
||||
private final Class<?> _next;
|
||||
|
||||
public final LongClickHandler longClickHandler = new LongClickHandler();
|
||||
public final PageButtonHandler pageButtonHandler = new PageButtonHandler();
|
||||
|
||||
PageHelper(Context curr,Class<?> prev,Class<?> next){
|
||||
_curr = curr;
|
||||
_prev = prev;
|
||||
|
@ -31,4 +36,19 @@ public class PageHelper {
|
|||
startActivity(_curr,myIntent,null);
|
||||
}
|
||||
|
||||
private final class LongClickHandler implements View.OnLongClickListener
|
||||
{
|
||||
@Override
|
||||
public boolean onLongClick(View v){
|
||||
goPrev();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private final class PageButtonHandler implements View.OnClickListener
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
goNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue