Advertisement
Guest User

Untitled

a guest
May 19th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 19.43 KB | None | 0 0
  1. package com.exampleC.layouttable24;
  2.  
  3. import static java.lang.Integer.toBinaryString;
  4.  
  5. import androidx.appcompat.app.AppCompatActivity;
  6.  
  7. import android.animation.ArgbEvaluator;
  8. import android.animation.TimeAnimator;
  9. import android.graphics.Color;
  10. import android.os.Bundle;
  11.  
  12. import android.text.Html;
  13. import android.text.SpannableStringBuilder;
  14. import android.text.Spanned;
  15. import android.text.TextPaint;
  16. import android.text.style.ForegroundColorSpan;
  17. import android.view.View;
  18.  
  19. import android.view.View.OnClickListener;
  20. import android.widget.Button;
  21. import android.widget.EditText;
  22. import android.widget.TableRow;
  23.  
  24. import android.widget.TextView;
  25. import android.widget.TableLayout;
  26.  
  27. import android.text.TextUtils;
  28.  
  29. import com.exampleC.layouttable24.R;
  30.  
  31. public class MainActivity extends AppCompatActivity {
  32.     public boolean g = true;
  33.     public Integer N = 1;
  34.     public String a = "2";
  35.     private EditText editText1;
  36.     private EditText linear;
  37.     private Integer[] hodnoty = new Integer[10];
  38.     private String[] koal = new String[10];
  39.     private float[] shap = new float[10];
  40.  
  41.     @Override
  42.     protected void onCreate(Bundle savedInstanceState) {
  43.         super.onCreate(savedInstanceState);
  44.         setContentView(R.layout.activity_main);
  45.         Button button4=findViewById(R.id.button4);
  46.         Button button7=findViewById(R.id.button7);
  47.  
  48.         button4.setOnClickListener(
  49.                 new Button.OnClickListener() {
  50.                     public void onClick(View view) {
  51.                         //     TextView status=findViewById(R.id.button9);
  52.  
  53.                         click4(view);
  54. //                    button9.setText("OK");
  55.                     }
  56.                 }
  57.  
  58.  
  59.         );
  60.  
  61.         button7.setOnClickListener(
  62.                 new Button.OnClickListener() {
  63.                     public void onClick(View view) {
  64.                         //     TextView status=findViewById(R.id.button9);
  65.  
  66.                         click7(view);
  67. //                    button9.setText("OK");
  68.                     }
  69.                 }
  70.  
  71.  
  72.         );
  73.  
  74.     }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.     public boolean iswinning(Integer J, int ii) {
  81.         return true;
  82.  
  83.     }
  84.  
  85.     public Integer fact(Integer f) {
  86.         if (f == 0) return 1;
  87.         else return f * fact((Integer) (f - 1));
  88.     }
  89.  
  90.     //T pocetHracu
  91.  
  92.     //  public Integer[] S = new Integer[toBinaryString(N - 1).length()];
  93.  
  94.     public boolean areDisjoint(Integer I,Integer J) {
  95.         int pocetHracu= toBinaryString(N-1).length();
  96.  
  97.         String StringPadded1=stf(toBinaryString(I),pocetHracu- toBinaryString(I).length());
  98.         String StringPadded2=stf(toBinaryString(J),pocetHracu- toBinaryString(J).length());
  99.  
  100.         Integer[] koal1= stringToArray(StringPadded1);
  101.         Integer[] koal2= stringToArray(StringPadded2);
  102.  
  103.  
  104.         for(int i=0;i<pocetHracu;i++) {
  105.             if (koal1[i]==1 & koal2[i]==1) {
  106.                 return false;
  107.             }
  108.         }
  109.         return true;
  110.  
  111.     }
  112.  
  113.  
  114.     public Integer union(Integer I,Integer J) {
  115.         int pocetHracu= toBinaryString(N-1).length();
  116.  
  117.         String StringPadded1=stf(toBinaryString(I),pocetHracu- toBinaryString(I).length());
  118.         String StringPadded2=stf(toBinaryString(J),pocetHracu- toBinaryString(J).length());
  119.         String StringPaddedVysl=stf(toBinaryString(0),pocetHracu-1);
  120.  
  121.  
  122.         Integer[] koal1= stringToArray(StringPadded1);
  123.         Integer[] koal2= stringToArray(StringPadded2);
  124.         Integer[] koalVysl=stringToArray(StringPaddedVysl);
  125.  
  126.         Integer vysl=0;
  127.  
  128.         for(int i=0;i<pocetHracu;i++) {
  129. //            koalVysl[i]=koal1[i]+koal2[i];
  130.             vysl+=power(pocetHracu-1-i)*(koal1[i]+koal2[i]);
  131.  
  132.  
  133.         }
  134.  
  135. //         vysl=4*(koal1[0]+koal2[0])+2*(koal1[1]+koal2[1])+(koal1[2]+koal2[2]);
  136.         return vysl;
  137.  
  138.     }
  139.  
  140.  
  141.     public Integer power(Integer p) {
  142.         if(p==0) {
  143.             return 1;
  144.         }
  145.         return 2*power(p-1);
  146.  
  147.     }
  148.  
  149.     public float K1=0, K2=0, K3=0, K4, K5;
  150.  
  151.     public boolean isSA(float[] vyhryKoalici) {
  152.         for(Integer I=0;I<N;I++) {
  153.             for(Integer J=0;J<N;J++) {
  154.                 if(areDisjoint(I,J)) {
  155.                     if (vyhryKoalici[union(I,J)]<vyhryKoalici[I]+vyhryKoalici[J]) {
  156.                         K1=union(I,J);K2=vyhryKoalici[I];K3=vyhryKoalici[J];
  157.                         return false;
  158.                     }
  159.  
  160.                 }
  161.             }
  162.         }
  163.  
  164.         return true;
  165.     }
  166.  
  167.  
  168.  
  169.  
  170.     public Integer[] stringToArray(String binary) {
  171.         Integer[] arrayOfPLayers=new Integer[binary.length()];
  172.         for(int i=0;i<binary.length();i++) {
  173.             arrayOfPLayers[i]=Integer.parseInt("" + binary.charAt(i));
  174.  
  175.         }
  176.         return arrayOfPLayers;
  177.     }
  178.  
  179.     //N je pocet koalici
  180.     public void click5(View view) {
  181.  
  182.         int pocetHracu= toBinaryString(N-1).length();
  183.         Integer[][] koalice=new Integer[N][pocetHracu];
  184.         Integer[][] koalice2=new Integer[N][pocetHracu];
  185.         Integer[][] koalice3=new Integer[N][pocetHracu];
  186.  
  187.  
  188.  
  189.         for (Integer ith=0;ith<N;ith++) {
  190.             for(Integer T=0;T<pocetHracu;T++) {
  191.                 String StringPadded=stf(toBinaryString(ith),pocetHracu- toBinaryString(ith).length());
  192.                 koalice[ith][T]=stringToArray(StringPadded)[T];
  193.                 koalice2[ith][T]=stringToArray(StringPadded)[T];
  194.                 koalice3[ith][T]=stringToArray(StringPadded)[T];
  195.             }
  196.         }
  197.         float[] shap=new float[pocetHracu];
  198.         float[] vyhryKoalici = new float[N];
  199.         Integer[] isSwing=new Integer[pocetHracu];
  200.  
  201.         for (int i=0; i<N;i++) {
  202.             editText1 = (EditText) findViewById(330+i);
  203.             String a=editText1.getText().toString();
  204.             float f1 = Float.parseFloat(a);
  205.             vyhryKoalici[i]=f1;
  206.         }
  207.  
  208.         Integer[] kolikJeSwingu=  new Integer[pocetHracu];
  209.  
  210.  
  211.  
  212.  
  213.         String S="";
  214.  
  215.         String kde="j";
  216.  
  217.         Integer jth;
  218.         for (int p = 0; p < pocetHracu; p++) {
  219.             isSwing[p] =0;
  220.             kolikJeSwingu[p]=N;
  221.         }
  222.  
  223. //        Integer swingove2=pocetHracu*N;
  224.         Integer bool=1;
  225.         Integer canBanzhaf=1;
  226.  
  227.         for(Integer contr=0;contr<N;contr++)
  228.         {
  229.             if(vyhryKoalici[contr]!=0 && vyhryKoalici[contr]!=1) {
  230.                 canBanzhaf=0;
  231.             }
  232.         }
  233.         for(Integer T=0;T<pocetHracu;T++) {
  234.             for (Integer ith = 0; ith < N; ith++) {
  235.  
  236.                 bool = 1;
  237.  
  238. //vyhryKoalici[ith];
  239. //musis najit jth<N pro ktere koalice3[jth]=S-ith
  240.                 if ((koalice[ith][T] == 1) && (vyhryKoalici[ith]==1)) {
  241.                     koalice3[ith][T] = 0;
  242.                     for (jth = 0; jth < N; jth++) {
  243.                         for (Integer k = 0; k < pocetHracu; k++)
  244.                         {
  245.                             //if (k != T && koalice[ith][k] != koalice3[jth][k]) {
  246.                             if ((k != T) && (koalice[ith][k] != koalice3[jth][k])) {
  247.                                 bool = 0;
  248.                                 //   swingove2--;
  249.                                 kde+="\nk"+k.toString()+"T"+T.toString()+">";
  250.                             }
  251.                         }
  252.                         kde+="\njth"+jth.toString()+"ith"+ith.toString()+"T"+T.toString();
  253. //(vyhryKoalici[jth]
  254.                         if ((vyhryKoalici[jth]==0) && (bool == 1)) {
  255.                             isSwing[T]++;
  256.                         }
  257.                         bool=1;
  258.                     }
  259.                     koalice3[ith][T]=1;
  260.                     bool=1;
  261.                 }
  262.  
  263.             }
  264.         }
  265.  
  266.  
  267.  
  268. //kolikJeSwingu(Integer TmaSwing, Integer pocetHracu, Integer pocetKoalici,
  269. //                                   Integer[][] koal, Integer[] koalicePriKtereJeSwing, float[] vyhryKoal)
  270.  
  271.         for (Integer ith = 0; ith < N; ith++) {
  272.             for(Integer T=0;T<pocetHracu;T++) {
  273. //isSwingBool(Integer kteraKoalice, Integer TmaSwing, Integer pocetHracu, Integer pocetKoalici,
  274. //                               Integer[][] koal, Integer[] koalicePriKtereJeSwing, float[] vyhryKoal) {
  275.  
  276.                 //   kolikJeSwingu[T]+=kolikJeSwingu(T, pocetHracu, N,
  277.                 //          koalice, koalice[ith],vyhryKoalici);
  278.  
  279.  
  280.                 if (koalice[ith][T] == 1) {
  281.                     koalice2[ith][T] = 0;
  282.                     for (jth = 0; jth < N; jth++) {
  283.                         bool = 1;
  284.                         for (int k = 0; k < pocetHracu; k++) {
  285.                             if (k != T && koalice[ith][k] != koalice2[jth][k]) {
  286.                                 bool = 0;
  287.                             }
  288.                         }
  289.  
  290.                         int bool2=0;
  291.                         koalice2[ith][T] = 1;
  292.  
  293.                         if (vyhryKoalici[ith] == 1 && vyhryKoalici[jth] == 0) {
  294.                             for (int k = 0; k < pocetHracu; k++) {
  295.                                 if (koalice[ith][k] != koalice2[jth][k]) {
  296.                                     bool2++;
  297.                                 }
  298.                             }
  299.  
  300.                             //    if(bool2==1) {
  301.                             //       isSwing[T]++;
  302.                             //   }
  303.  
  304.                         }
  305.                         koalice2[ith][T] = 1;
  306.                         Integer t = 0;
  307.                         for (int p = 0; p < pocetHracu; p++) {
  308.                             t += koalice[ith][p];
  309.                         }
  310.                         // Integer[] isSwing=new Integer[pocetHracu];
  311.  
  312.                         if (bool == 1) {
  313.                             shap[T] += (float) ((float) fact(t - 1) * fact(pocetHracu - t) / (float) (fact(pocetHracu)) * (float) (vyhryKoalici[ith] - vyhryKoalici[jth]));
  314.                         }
  315.                     }
  316.                 }
  317.  
  318.             }
  319.         }
  320.  
  321.  
  322.         S+="here";
  323.         String T2="";
  324.         T2+="banzhaf";
  325.  
  326.         Integer swingove=0;
  327.         Integer totWin=0;
  328.         Integer totLos=0;
  329.  
  330.  
  331.  
  332.  
  333.         for(int p=0;p<pocetHracu;p++) {
  334.             swingove+=isSwing[p];
  335.         }
  336.  
  337.         for(int i=0;i<N;i++) {
  338.             if(vyhryKoalici[i]==1) {
  339.                 totWin++;
  340.             }
  341.  
  342.             if(vyhryKoalici[i]==0) {
  343.                 totLos++;
  344.             }
  345.         }
  346.  
  347.  
  348.         String strPokus="";
  349.         String strPokusColWin="";
  350.         String strPokusColLos="";
  351.  
  352.  
  353.         if(canBanzhaf==1) {
  354.             strPokus = "banzhaf ";
  355.             strPokusColWin="coleman winning ";
  356.             strPokusColLos="coleman loosing ";
  357.  
  358.         } else {
  359.             strPokus="banzhaf err ";
  360.             strPokusColWin="coleman winning err ";
  361.             strPokusColLos="coleman loosing err ";
  362.  
  363.         }
  364.  
  365.         float[] banzh=new float[pocetHracu];
  366.         float[] colemanWin=new float[pocetHracu];
  367.         float[] colemanLos=new float[pocetHracu];
  368.  
  369.         for(int p=0;p<pocetHracu;p++)
  370.         {
  371.             banzh[p]=(float) isSwing[p]/(float) swingove;
  372.             colemanWin[p]=(float) isSwing[p]/(float) totWin;
  373.             colemanLos[p]=(float) isSwing[p]/(float) totLos;
  374.         }
  375.  
  376.  
  377.         String strPokus2="shap ";
  378.  
  379.         for(int i=0;i<pocetHracu;i++) {
  380.             //   S+=(" "+String.valueOf(shap[i]));
  381.             strPokus2+=String.format("%.2f ",shap[i]);
  382.             strPokus+=String.format("%.2f ",banzh[i]);
  383.             strPokusColWin+=String.format("%.2f ",colemanWin[i]);
  384.             strPokusColLos+=String.format("%.2f ",colemanLos[i]);
  385.         }
  386.  
  387.  
  388.         // tv6.setText(strPokus2+"\n"+strPokus+"\nswing"+isSwing[0]+"swingPrvni:"+isSwing[1]+"\nH"+swingove);
  389.         TextView tv6 = (TextView) findViewById(R.id.tvMarque);
  390.         //     tv6.setSingleLine(true);
  391.         tv6.setMarqueeRepeatLimit(-1);
  392.         tv6.setEllipsize(TextUtils.TruncateAt.MARQUEE);
  393.         tv6.setSelected(true);
  394.  
  395.         String SA;
  396.         if(isSA(vyhryKoalici)) {
  397.             SA="";
  398.         }
  399.         else {
  400.             SA="here superadditivity fails "+(int) K1+" "+K2+" "+K3;
  401.         }
  402.  
  403.         tv6.setText(strPokus2+"\n"+strPokus+"\n"+strPokusColWin+"\n"+strPokusColLos+"\n"+"number of winning "+totWin+"\n"+"number of loosing "+totLos+"\nis super additve "+isSA(vyhryKoalici)+"\n"+SA);
  404.  
  405.  
  406.         TextView tv7 = (TextView) findViewById(R.id.tvMarque2);
  407.         tv7.setSingleLine(true);
  408.         tv7.setMarqueeRepeatLimit(-1);
  409.         tv7.setEllipsize(TextUtils.TruncateAt.MARQUEE);
  410.         tv7.setSelected(true);
  411. //        tv7.setText("         * *            *          * *           *           *  *            *           ");
  412.  
  413. //        tv7.setText(Html.fromHtml("        * *            *          * *           <b><p style=color:yellow;>*</p></b>           *  *            *           "));
  414.  
  415. //        tv7.setText(Html.fromHtml("**<p style=color:green;>  *&nbsp;T*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));
  416.  
  417. //        tv7.setText(Html.fromHtml("**<p style=color:green>  *&nbsp;T*</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));
  418.         SpannableStringBuilder ssb = new SpannableStringBuilder();
  419.         ssb.append(Html.fromHtml("**<p style=color:green>  *&nbsp;**</p>\n<ul><li>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:green;>*</p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<p style=color:red;>*</p>*  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           </li></ul>"));
  420.         int blinkTextIndex = 6;
  421.         ssb.setSpan(new FCS(tv7, new int[] {Color.RED, Color.YELLOW}), blinkTextIndex, blinkTextIndex + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  422.         tv7.setText(ssb);
  423.  
  424.         //  String html = "<html><body><p>Hello world</p></body></html>";
  425.         //    String baseUrl = "https://example.com/";
  426.  
  427. //        WebView mWebView;
  428.         //      mWebView.loadDataWithBaseURL(baseUrl, html, "text/html", null, baseUrl);
  429.  
  430. //tv6.setText("11bbbb"+"bDDDDDDDjjjjjjjjjjppppppppppppppDDbbbbbbbbbb");
  431. //        TextView textView=(TextView)findViewById(R.id.text_test);
  432.      /*   tv6.setEllipsize(TextUtils.TruncateAt.MARQUEE);
  433.         tv6.setSingleLine(true);
  434.         tv6.setMarqueeRepeatLimit(-1);
  435.         tv6.setFocusableInTouchMode(true);
  436.         tv6.setFocusable(true);
  437.  
  438. */
  439.  
  440.     /*    TextView txt = new TextView(this);
  441.         txt.setText("This is the infinite marquee");
  442.         txt.setEllipsize(TextUtils.TruncateAt.MARQUEE);
  443.         txt.setSingleLine(true);
  444.         txt.setMarqueeRepeatLimit(-1);
  445.         txt.setSelected(true);
  446.       */
  447.  
  448.     }
  449.  
  450.     public void click4(View view) {
  451.         //
  452.  
  453.         if (g) {
  454.  
  455.             linear = (EditText) findViewById(R.id.simpleEditText);
  456.             if (N == 1) {
  457.                 linear.setText("1");
  458.             }
  459.  
  460.             String a = linear.getText().toString();
  461.             N = Integer.parseInt(a);
  462.             N++;
  463.             linear.setText(N.toString());
  464.  
  465.  
  466.         }
  467.     }
  468.     public void click7(View view) {
  469.         if (g) {
  470.  
  471.             //
  472.             linear = (EditText) findViewById(R.id.simpleEditText);
  473.             if (N == 0 || N == 1) {
  474.                 linear.setText("1");
  475.             }
  476.  
  477.             String a = linear.getText().toString();
  478.             N = Integer.parseInt(a);
  479.             if (N > 1) N--;
  480.             linear.setText(N.toString());
  481.  
  482.  
  483.         }
  484.     }
  485.  
  486.     public  String stf(String a,Integer l) {
  487.         if(l==0) { return a; }
  488.         l--;
  489.         return stf("0"+a,l);
  490.  
  491.     }
  492.     public void click2(View view) {
  493.         if (g) {
  494.             g = false;
  495.  
  496.             String col1;
  497.             String col2;
  498.             //  String playerChanged;
  499.  
  500.             TableLayout tl = (TableLayout) findViewById(R.id.tableLayout1);
  501.  
  502.             EditText editText = (EditText) findViewById(R.id.simpleEditText);
  503.  
  504.  
  505.             TableRow row = new TableRow(this);
  506.             TextView tv = new TextView(this);
  507.             TextView c = new TextView(this);
  508.  
  509.             //EditText etUserInfoNewValue = (EditText)findViewById(R.id.simpleEditText);
  510.             //  a = editText.getText().toString();
  511.  
  512.             //  tv.setId(202);
  513.  
  514.  
  515.             tv.setText("This is text");
  516. //
  517.             tl.addView(row);
  518.  
  519.             row.addView(tv);
  520.  
  521.             int sf = toBinaryString(N - 1).length();
  522.             for (int x = 0; x < N; x++) {
  523.                 //String.format("0d",(
  524.                 String jl = toBinaryString(x);
  525.                 String jl2 = stf(jl, sf - jl.length());
  526. //koal[x]=jl2;
  527.                 col1 = "(" + x + ")" + jl2;
  528.                 // col1 = "(" + x + ")"+Integer.toBinaryString(x);
  529.                 col2 = "1";
  530.  
  531.                 //col3 = "(" + x + ") Column 3";
  532.                 //col4 = "(" + x + ") Column 4";
  533.  
  534.                 TableRow newRow = new TableRow(this);
  535.  
  536.                 TextView column1 = new TextView(this);
  537.                 TextView column2 = new TextView(this);
  538.                 EditText editText1 = new EditText(this);
  539.  
  540.                 editText1.setId(330 + x);
  541.                 // String stringAnswer = editText1.getText().toString();
  542.  
  543.                 TextView column3 = new TextView(this);
  544.                 // TextView column4 = new TextView(this);
  545.                 editText1.setText("0        ");
  546.                 column1.setText(col1);
  547.                 column1.setText(col1);
  548.                 column2.setText(col2);
  549.                 //column3.setText(col3);
  550.                 //column4.setText(col4);
  551.  
  552.                 // column1.setText(stringAnswer);
  553.  
  554.                 newRow.addView(column1);
  555.                 newRow.addView(editText1);
  556.  
  557.  
  558.                 newRow.addView(column3);
  559.                 // newRow.addView(column4);
  560.  
  561.                 tl.addView(newRow, new TableLayout.LayoutParams());
  562.             }
  563.  
  564.         }
  565.     }
  566.  
  567. }
  568.  
  569.  
  570.  
  571. class FCS extends ForegroundColorSpan implements TimeAnimator.TimeListener {
  572.  
  573.     private TextView tv;
  574.     private int[] colors;
  575.     private int color;
  576.     TimeAnimator animator;
  577.     ArgbEvaluator evaluator;
  578.  
  579.     public FCS(TextView tv, int[] colors) {
  580.         super(colors[0]);
  581.         this.tv = tv;
  582.         this.colors = colors;
  583.         animator = new TimeAnimator();
  584.         animator.setTimeListener(this);
  585.         evaluator = new ArgbEvaluator();
  586.         animator.start();
  587.     }
  588.  
  589.     @Override
  590.     public void updateDrawState(TextPaint ds) {
  591.         ds.setColor(color);
  592.     }
  593.  
  594.     @Override
  595.     public void onTimeUpdate(TimeAnimator animation, long totalTime, long deltaTime) {
  596.         float sin = (float) (Math.sin(Math.PI * totalTime / 400f));
  597.         float fraction = sin * sin;
  598. //            float fraction = (float) (-Math.cos(2*Math.PI * totalTime / 1000f) + 1) / 2f;
  599.         color = (int) evaluator.evaluate(fraction, colors[0], colors[1]);
  600.         tv.invalidate();
  601.         if (totalTime < -1) {
  602.             animator.end();
  603.         }
  604.     }
  605.  
  606. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement