Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.teachme.activities.Managers.StudentViews.StudentsTasks.Fragments;
- import android.animation.Animator;
- import android.animation.AnimatorListenerAdapter;
- import android.animation.ArgbEvaluator;
- import android.animation.ObjectAnimator;
- import android.animation.ValueAnimator;
- import android.annotation.SuppressLint;
- import android.graphics.drawable.AnimationDrawable;
- import android.graphics.drawable.ColorDrawable;
- import android.graphics.drawable.Drawable;
- import android.graphics.drawable.TransitionDrawable;
- import android.os.Handler;
- import android.support.constraint.ConstraintLayout;
- import android.support.v4.app.Fragment;
- import android.app.ProgressDialog;
- import android.graphics.Bitmap;
- import android.graphics.BitmapFactory;
- import android.graphics.Color;
- import android.os.AsyncTask;
- import android.os.Build;
- import android.os.Bundle;
- import android.support.annotation.NonNull;
- import android.support.annotation.RequiresApi;
- import android.util.Base64;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewAnimationUtils;
- import android.view.ViewGroup;
- import android.view.animation.Animation;
- import android.view.animation.LinearInterpolator;
- import android.view.animation.RotateAnimation;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.LinearLayout;
- import android.widget.RelativeLayout;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.teachme.DB.Pattern;
- import com.teachme.DB.PatternStudent;
- import com.teachme.DB.RestClient;
- import com.teachme.R;
- import com.teachme.activities.Managers.ForCheckAnswer;
- import com.teachme.activities.Managers.ImageManager;
- import com.teachme.activities.Managers.StudentViews.ShowCourseLessonStudent;
- import com.teachme.global.Global_config;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.io.ByteArrayOutputStream;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- import retrofit2.Call;
- import retrofit2.Callback;
- import retrofit2.Response;
- /**
- * Created by andyshon on 02.01.18.
- */
- public class TaskStudentFindPictureFragment extends Fragment implements View.OnClickListener {
- static final String ARGUMENT_PAGE_NUMBER = "arg_page_number";
- //ConstraintLayout mainLayout;
- RestClient restClient;
- public String _Pattern_Id, _Lesson_Id, lesson_title, pattern_title;
- boolean swap = false;
- boolean userClickedButton = false;
- Button button1, button2;
- String rightAnswer, wrongAnswer1, wrongAnswer2, wrongAnswer3;
- //ImageView imageView;
- TextView tv_title;
- int pageNumber;
- public static int backColor;
- AnimationDrawable animationDrawable;
- ProgressDialog progressDialog;
- //ImageView imageView1, imageView2, imageView3, imageView4;
- Bitmap bitmap;
- ImageView image, image2;
- public TaskStudentFindPictureFragment newInstance(int page) {
- System.out.println("this._Pattern_Id = " +this._Pattern_Id);
- TaskStudentFindPictureFragment taskStudentFindPictureFragment = new TaskStudentFindPictureFragment();
- Bundle arguments = new Bundle();
- arguments.putInt(ARGUMENT_PAGE_NUMBER, page);
- taskStudentFindPictureFragment.setArguments(arguments);
- return taskStudentFindPictureFragment;
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- System.out.println("restClient is Ready!");
- pageNumber = getArguments().getInt(ARGUMENT_PAGE_NUMBER);
- }
- @RequiresApi(api = Build.VERSION_CODES.M)
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- System.out.println("[STUDENT MODE] : =pagenumber = " + pageNumber);
- System.out.println("TASKSTUDENT choose word image!!!");
- /* Вкладка НАЙТИ СЛОВО */
- final View view = inflater.inflate(R.layout.task_student_find_picture, null);
- //mainLayout = view.findViewById(R.id.mainLayout_find_picture);
- //mainLayout.setVisibility(View.INVISIBLE);
- /*btn1 = view.findViewById(R.id.btn1);
- btn1.setOnClickListener(this);
- btn2 = view.findViewById(R.id.btn2);
- btn2.setOnClickListener(this);
- btn3 = view.findViewById(R.id.btn3);
- btn3.setOnClickListener(this);
- btn4 = view.findViewById(R.id.btn4);
- btn4.setOnClickListener(this);*/
- //btnCheckTaskFindPicture = view.findViewById(R.id.btnCheckTaskFindPicture);
- //btnCheckTaskFindPicture.setOnClickListener(this);
- button1 = view.findViewById(R.id.button1);
- button1.setOnClickListener(this);
- button2 = view.findViewById(R.id.button2);
- button2.setOnClickListener(this);
- image = view.findViewById(R.id.image);
- //image.setBackgroundResource(R.drawable.ic_launcher_background);
- image2 = view.findViewById(R.id.image2);
- /*imageView1 = view.findViewById(R.id.imageView1);
- imageView1.setVisibility(View.VISIBLE);
- imageView2 = view.findViewById(R.id.imageView2);
- imageView2.setVisibility(View.VISIBLE);
- imageView3 = view.findViewById(R.id.imageView3);
- imageView3.setVisibility(View.VISIBLE);
- imageView4 = view.findViewById(R.id.imageView4);
- imageView4.setVisibility(View.VISIBLE);*/
- tv_title = view.findViewById(R.id.title);
- tv_title.setTextSize(22);
- tv_title.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
- //imageView = view.findViewById(R.id.imageView);
- /*if (swap){
- btnCheckTaskFindPicture.setBackgroundColor(Color.rgb(153, 204, 0));
- btnCheckTaskFindPicture.setTextColor(Color.WHITE);
- btnCheckTaskFindPicture.setText("Продолжить");
- }*/
- @SuppressLint("StaticFieldLeak")
- class AsyncTaskUploadClass extends AsyncTask<Void, Void, String> {
- @Override
- protected void onPreExecute() {
- super.onPreExecute();
- //progressDialog = ProgressDialog.show(getContext(),
- // "Картинка загружается", "Пожалуйста подождите", false, true);
- }
- @Override
- protected void onPostExecute(String string1) {
- super.onPostExecute(string1);
- //progressDialog.dismiss();
- //Toast.makeText(getContext(), "onPostExecute", Toast.LENGTH_SHORT).show();
- }
- @Override
- protected String doInBackground(Void... params) {
- // TODO: Узнать прошел ли студент это задание (isDone)
- restClient = new RestClient();
- Call<List<PatternStudent>> call0 = restClient.getService().getPatternStudentsByPatternId(_Pattern_Id);
- call0.enqueue(new Callback<List<PatternStudent>>() {
- @Override
- public void onResponse(@NonNull Call<List<PatternStudent>> call, @NonNull Response<List<PatternStudent>> response) {
- for (int i = 0; i < response.body().size(); i++) {
- if (response.body().get(i).getPatternId().equals(_Pattern_Id))
- swap = response.body().get(i).getIsDone();
- }
- System.out.println("SWAP onStart = " + swap);
- }
- @Override
- public void onFailure(@NonNull Call<List<PatternStudent>> call, @NonNull Throwable t) {
- Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_LONG).show();
- }
- }
- );
- //TODO: Получить данные задания
- restClient = new RestClient();
- Call<Pattern> call = restClient.getService().getPatternById(_Pattern_Id);
- call.enqueue(new Callback<Pattern>() {
- @Override
- public void onResponse(@NonNull Call<Pattern> call, @NonNull Response<Pattern> response) {
- Pattern pattern = response.body();
- _Lesson_Id = pattern.getLessonId();
- pattern_title = pattern.getName();
- tv_title.setText(pattern_title);
- System.out.println("pattern.getJsonText::" + pattern.getJsonText());
- String text=null;
- try {
- JSONObject jsonObject2 = new JSONObject(pattern.getJsonText());
- JSONArray jsonArray = jsonObject2.getJSONArray("FindPicture");
- JSONObject exploredObj = jsonArray.getJSONObject(0);
- text = exploredObj.getString("textMessage");
- System.out.println("String text:" + text);
- exploredObj = jsonArray.getJSONObject(1);
- rightAnswer = exploredObj.getString("rightAnswer");
- System.out.println("rightAnswer json:" + rightAnswer);
- exploredObj = jsonArray.getJSONObject(2);
- wrongAnswer1 = exploredObj.getString("wrongAnswer1");
- System.out.println("wrongAnswer1 json:" + wrongAnswer1);
- exploredObj = jsonArray.getJSONObject(3);
- wrongAnswer2 = exploredObj.getString("wrongAnswer2");
- System.out.println("wrongAnswer2 json:" + wrongAnswer2);
- exploredObj = jsonArray.getJSONObject(4);
- wrongAnswer3 = exploredObj.getString("wrongAnswer3");
- System.out.println("wrongAnswer3 json:" + wrongAnswer3);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- ArrayList<Button> buttons = new ArrayList<>();
- /*buttons.add(btn1);
- buttons.add(btn2);
- buttons.add(btn3);
- buttons.add(btn4);*/
- /*Collections.shuffle(buttons);
- ArrayList<String> answers = new ArrayList<>();
- answers.add(rightAnswer);
- answers.add(wrongAnswer1);
- answers.add(wrongAnswer2);
- answers.add(wrongAnswer3);
- Collections.shuffle(answers);
- for (int i=0; i<buttons.size(); i++){
- buttons.get(i).setText(answers.get(i));
- }*/
- /*if (Math.random() > 0.5) {
- btn1.setText(rightAnswer);
- btn2.setText(wrongAnswer1);
- btn3.setText(wrongAnswer2);
- btn4.setText(wrongAnswer3);
- } else {
- btn1.setText(wrongAnswer1);
- btn2.setText(rightAnswer);
- }*/
- //byte[] decodedString = Base64.decode(text, Base64.DEFAULT);
- //Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
- //System.out.println("DecodedByte onStart() = " + decodedByte);
- //imageView.setImageBitmap(decodedByte);
- System.out.println("BLOB GOING....");
- final ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
- final Handler handler = new Handler();
- System.out.println("BLOB THREAD....");
- final String finalText = text;
- Thread th = new Thread(new Runnable() {
- public void run() {
- try {
- long imageLength = 0;
- ImageManager.GetImage(/*image*/finalText, imageStream, imageLength);
- System.out.println("BLOB GetImage....");
- handler.post(new Runnable() {
- public void run() {
- byte[] buffer = imageStream.toByteArray();
- bitmap = BitmapFactory.decodeByteArray(buffer, 0, buffer.length);
- System.out.println("BLOB bitmap...." + bitmap);
- //Toast.makeText(getContext(), "Got it bitmap!", Toast.LENGTH_SHORT).show();
- //image.setImageBitmap(bitmap);
- image.setImageResource(R.drawable.ic_close_white_240dp);
- show(image);
- //image.setImageBitmap(bitmap);
- image2.setImageResource(R.drawable.attention512);
- show(image2);
- //imageView.setImageBitmap(bitmap);
- //imageView1.setImageBitmap(bitmap);
- //imageView2.setImageBitmap(bitmap);
- //imageView3.setImageBitmap(bitmap);
- //imageView4.setImageBitmap(bitmap);
- //mainLayout.setVisibility(View.VISIBLE);
- }
- });
- } catch (Exception ex) {
- final String exceptionMessage = ex.getMessage();
- handler.post(new Runnable() {
- public void run() {
- Toast.makeText(getContext(), exceptionMessage, Toast.LENGTH_SHORT).show();
- }
- });
- }
- }
- });
- th.start();
- //mainLayout.setVisibility(View.VISIBLE);
- }
- @Override
- public void onFailure(@NonNull Call<Pattern> call, @NonNull Throwable t) {
- Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_LONG).show();
- }
- });
- return null;
- }
- }
- AsyncTaskUploadClass AsyncTaskUploadClassOBJ = new AsyncTaskUploadClass();
- AsyncTaskUploadClassOBJ.execute();
- // здесь код выполняется асинхронно
- return view;
- }
- @RequiresApi(api = Build.VERSION_CODES.M)
- @Override
- public void onClick(View v) {
- switch (v.getId()){
- case R.id.button1:
- //btnSingleEvent(button1);
- //image.setImageBitmap(bitmap);
- show(image);
- break;
- case R.id.button2:
- //btnSingleEvent(button2);
- //image.setImageBitmap(bitmap);
- show(image2);
- break;
- /*case R.id.btn1:
- userClickedButton = true;
- btnSingleEvent(btn1);
- break;
- case R.id.btn2:
- userClickedButton = true;
- btnSingleEvent(btn2);
- break;
- case R.id.btn3:
- userClickedButton = true;
- btnSingleEvent(btn3);
- break;
- case R.id.btn4:
- userClickedButton = true;
- btnSingleEvent(btn4);
- break;*/
- /*case R.id.btnCheckTaskChooseWordImage:
- new ForCheckAnswer().checkWholeTask(ShowCourseLessonStudent.patternsTypes.size(),
- ShowCourseLessonStudent.pager.getCurrentItem(),
- mainLayout, getContext());
- if (!swap) {
- if (userClickedButton) {
- *//*if (btn2.getText().equals(wrongAnswer))
- btn2.setBackgroundColor(Color.RED);
- else if (btn1.getText().equals(wrongAnswer))
- btn1.setBackgroundColor(Color.RED);*//*
- }
- else {
- Toast.makeText(getContext(), "Вы не выбрали ответ!", Toast.LENGTH_SHORT).show();
- }
- }
- else {
- int itemPosition = ShowCourseLessonStudent.pager.getCurrentItem();
- ShowCourseLessonStudent.pager.setCurrentItem(itemPosition+1);
- }
- break;*/
- }
- }
- // To reveal a previously invisible view using this effect:
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- private void show(final View view) {
- //final ImageView imageView = (ImageView) view;
- //imageView.setImageBitmap(bitmap);
- //imageView.invalidate();
- // get the center for the clipping circle
- int cx = (view.getLeft() + view.getRight()) / 2;
- int cy = (view.getTop() + view.getBottom()) / 2;
- // get the final radius for the clipping circle
- int finalRadius = Math.max(view.getWidth(), view.getHeight());
- // create the animator for this view (the start radius is zero)
- Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius);
- anim.setDuration(1000);
- // make the view visible and start the animation
- //imageView.setVisibility(View.VISIBLE);
- // make the view invisible when the animation is done
- /*anim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- super.onAnimationEnd(animation);
- //view.setVisibility(View.INVISIBLE);
- Toast.makeText(getContext(), "TOAST", Toast.LENGTH_SHORT).show();
- }
- });*/
- anim.start();
- /*final Handler handler = new Handler();
- Thread th = new Thread(new Runnable() {
- public void run() {
- try {
- // get the center for the clipping circle
- int cx = (imageView.getLeft() + imageView.getRight()) / 2;
- int cy = (imageView.getTop() + imageView.getBottom()) / 2;
- // get the final radius for the clipping circle
- int finalRadius = Math.max(imageView.getWidth(), imageView.getHeight());
- // create the animator for this view (the start radius is zero)
- Animator anim = ViewAnimationUtils.createCircularReveal(imageView, cx, cy, 0, finalRadius);
- anim.setDuration(1500);
- // make the view visible and start the animation
- imageView.setVisibility(View.VISIBLE);
- anim.start();
- handler.post(new Runnable() {
- public void run() {
- try {
- Thread.sleep(1500);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- //int itemPosition = ShowCourseLessonStudent.customViewPager.getCurrentItem();
- //ShowCourseLessonStudent.customViewPager.setCurrentItem(itemPosition+1);
- }
- });
- } catch (Exception ex) {
- final String exceptionMessage = ex.getMessage();
- handler.post(new Runnable() {
- public void run() {
- Toast.makeText(getContext(), exceptionMessage, Toast.LENGTH_SHORT).show();
- }
- });
- }
- }
- });
- th.start();*/
- }
- @RequiresApi(api = Build.VERSION_CODES.M)
- private void btnSingleEvent(Button button){
- Button btn = button;
- //if (btn.getId() == R.id.button1){
- //image = getView().findViewById(R.id.image);
- //image.setBackgroundResource(R.drawable.ic_launcher_background);
- image.setImageBitmap(bitmap);
- int cx = (image.getLeft() + image.getRight()) / 2;
- int cy = (image.getTop() + image.getBottom()) / 2;
- // get the final radius for the clipping circle
- int finalRadius = Math.max(image.getWidth(), image.getHeight());
- // create the animator for this view (the start radius is zero)
- Animator anim = ViewAnimationUtils.createCircularReveal(image, cx, cy, 0, finalRadius);
- anim.setDuration(1000);
- anim.start();
- //}
- /*else if (btn.getId() == R.id.button2){
- image = getView().findViewById(R.id.image2);
- image.setBackgroundResource(R.drawable.ic_close_white_240dp);
- int cx = (image.getLeft() + image.getRight()) / 2;
- int cy = (image.getTop() + image.getBottom()) / 2;
- // get the final radius for the clipping circle
- int finalRadius = Math.max(image.getWidth(), image.getHeight());
- // create the animator for this view (the start radius is zero)
- Animator anim = ViewAnimationUtils.createCircularReveal(image, cx, cy, 0, finalRadius);
- anim.setDuration(1000);
- anim.start();
- }*/
- /*ImageView image1 = new ImageView(getContext());
- image1.setLeft(btn.getLeft());
- image1.setRight(btn.getRight());
- image1.setTop(btn.getTop());
- image1.setBottom(btn.getBottom());
- image1.setMaxWidth(500);
- image1.setMaxHeight(500);*/
- //image.setImageBitmap(bitmap);
- //image1.setLayoutParams(new android.view.ViewGroup.LayoutParams(500,500));
- //mainLayout.addView(image1);
- //show(image1);
- //LinearLayout layout = new LinearLayout(getContext());
- //layout.setOrientation(LinearLayout.VERTICAL);
- // TODO: Set attributes for layout
- // i.e. RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
- // layout.setLayoutParams(params);
- //ImageView imageView1 = new ImageView(getContext());
- //imageView1.setLeft(100);
- //image1.setLeft(btn3.getLeft());
- //image1.setRight(btn3.getRight());
- //image1.setTop(btn3.getTop());
- //image1.setBottom(btn3.getBottom());
- //image1.setMaxWidth(500);
- //image1.setMaxHeight(500);
- //imageView1.setBackgroundResource(R.drawable.ic_launcher_background);
- //ImageView imageView2 = new ImageView(getContext());
- //imageView2.setLeft(500);
- //imageView2.setBackgroundResource(R.drawable.ic_close_white_240dp);
- // TODO: Set LayoutParams for each imageView
- // i.e. RelativeLayout.LayoutParams imageParams1 = new RelativeLayout.LayoutParams(imageWidth, imageHeight);
- // imageParams1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
- // imageParams1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- //ViewGroup.LayoutParams layoutParams2 = new ViewGroup.LayoutParams(500,500);
- //layout.addView(imageView1, layoutParams2);
- //layout.addView(imageView2, layoutParams2);
- //mainLayout.addView(layout);
- /*show(imageView1);
- int cx2 = (imageView1.getLeft() + imageView1.getRight()) / 2;
- int cy2 = (imageView1.getTop() + imageView1.getBottom()) / 2;
- // get the final radius for the clipping circle
- int finalRadius2 = Math.max(imageView1.getWidth(), imageView1.getHeight());
- // create the animator for this view (the start radius is zero)
- Animator anim2 = ViewAnimationUtils.createCircularReveal(imageView1, cx, cy, 0, finalRadius);
- anim2.setDuration(1000);
- anim2.start();
- show(imageView2);
- int cx3 = (imageView2.getLeft() + imageView2.getRight()) / 2;
- int cy3 = (imageView2.getTop() + imageView2.getBottom()) / 2;
- // get the final radius for the clipping circle
- int finalRadius3 = Math.max(imageView2.getWidth(), imageView2.getHeight());
- // create the animator for this view (the start radius is zero)
- Animator anim3 = ViewAnimationUtils.createCircularReveal(imageView2, cx, cy, 0, finalRadius);
- anim3.setDuration(1000);
- anim3.start();*/
- // RotateAnimation anim = new RotateAnimation(0f, 350f, 15f, 15f);
- // anim.setInterpolator(new LinearInterpolator());
- // anim.setRepeatCount(Animation.INFINITE);
- // anim.setDuration(700);
- //
- // image1.startAnimation(anim);
- button.setVisibility(View.INVISIBLE);
- int id = button.getId();
- /*if (id == R.id.btn1){
- System.out.println("BTN 1");
- int shelfHeight = btn1.getHeight();
- int shelfWidth = btn1.getWidth();
- int shelfTop = btn1.getTop();
- int shelfLeft = btn1.getLeft();
- int shelfBottom = btn1.getBottom();
- int shelfRight = btn1.getRight();
- ImageView image = new ImageView(getActivity());
- image.setLeft(shelfLeft);
- image.setRight(shelfRight);
- image.setTop(shelfTop);
- image.setBottom(shelfBottom);
- image.setMaxWidth(shelfWidth+100);
- image.setMaxWidth(shelfHeight+100);
- image.setVisibility(View.VISIBLE);
- image.setImageBitmap(bitmap);
- System.out.println("IMAGE! = " + image.getDrawable() + " " + image.getRight());
- mainLayout.addView(image);
- //image.invalidate();
- show(image);
- button.setVisibility(View.INVISIBLE);
- //imageView1.setImageBitmap(bitmap);
- //show(imageView1);
- }
- if (id == R.id.btn2){
- System.out.println("BTN 2");
- int shelfHeight = btn2.getHeight()+250;
- int shelfWidth = btn2.getWidth()+250;
- int shelfTop = btn2.getTop();
- int shelfLeft = btn2.getLeft()+250;
- int shelfBottom = btn2.getBottom();
- int shelfRight = btn2.getRight()+250;
- ImageView image = new ImageView(getActivity());
- image.setLeft(shelfLeft);
- image.setRight(shelfRight);
- image.setTop(shelfTop);
- image.setBottom(shelfBottom);
- image.setMaxWidth(shelfWidth);
- image.setMaxWidth(shelfHeight);
- image.setVisibility(View.VISIBLE);
- image.setImageBitmap(bitmap);
- System.out.println("IMAGE! = " + image.getDrawable() + " " + image.getRight());
- ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(1000,1000);
- mainLayout.addView(image, layoutParams);
- //image.invalidate();
- show(image);
- btn1.setVisibility(View.INVISIBLE);
- button.setVisibility(View.INVISIBLE);
- //imageView2.setImageBitmap(bitmap);
- //show(imageView2);
- }
- if (id == R.id.btn3){
- button.setVisibility(View.INVISIBLE);
- //imageView3.setImageBitmap(bitmap);
- //show(imageView3);
- }
- if (id == R.id.btn4){
- button.setVisibility(View.INVISIBLE);
- //imageView4.setImageBitmap(bitmap);
- //show(imageView4);
- }*/
- if (button.getText().equals(/*rightAnswer*/"Dd")){
- int id2 = button.getId();
- /*if (id2 == R.id.btn1){
- button.setVisibility(View.INVISIBLE);
- //imageView1.setImageBitmap(bitmap);
- //show(imageView1);
- }
- if (id2 == R.id.btn2){
- button.setVisibility(View.INVISIBLE);
- //imageView2.setImageBitmap(bitmap);
- //show(imageView2);
- }
- if (id2 == R.id.btn3){
- button.setVisibility(View.INVISIBLE);
- //imageView3.setImageBitmap(bitmap);
- //show(imageView3);
- }
- if (id2 == R.id.btn4){
- button.setVisibility(View.INVISIBLE);
- //imageView4.setImageBitmap(bitmap);
- //show(imageView4);
- }*/
- //button.setVisibility(View.INVISIBLE);
- /*btnCheckTaskFindPicture.setBackgroundColor(Color.rgb(153, 204, 0));
- btnCheckTaskFindPicture.setTextColor(Color.WHITE);
- btnCheckTaskFindPicture.setText("Продолжить");*/
- //Toast.makeText(getContext(), "Правильно!", Toast.LENGTH_SHORT).show();
- //TODO: сохранить в бд в таблицу PatternStudent ид задания, ид студента и isDone = true
- /*PatternStudent patternstudent = new PatternStudent();
- patternstudent.setUserId(Global_config._USER_ID_CUR);
- patternstudent.setStudentAnswer("no answer");
- patternstudent.setIsDone(true);
- patternstudent.setPatternId(_Pattern_Id);
- System.out.println("_Pattern_Id ====" + _Pattern_Id);
- restClient.getService().addPatternStudent(patternstudent).enqueue(new Callback<PatternStudent>() {
- @Override
- public void onResponse(@NonNull Call<PatternStudent> call, @NonNull Response<PatternStudent> response) {
- if (response.code() == 201) {
- //Toast.makeText(getContext(), "New PatternStudent Registered.", Toast.LENGTH_LONG).show();
- } else {
- Toast.makeText(getContext(), "Not Created:" + response.errorBody(), Toast.LENGTH_LONG).show();
- }
- }
- @Override
- public void onFailure(@NonNull Call<PatternStudent> call, @NonNull Throwable t) {
- Toast.makeText(getContext(), t.getMessage(), Toast.LENGTH_LONG).show();
- }
- });*/
- swap = true;
- }
- else {
- swap = false;
- //AnimationDrawable animationDrawable = (AnimationDrawable) button.getBackground();
- //animationDrawable.start();
- //Drawable drawable = button.getBackground();
- //int c = button.getDrawingCacheBackgroundColor();
- //System.out.println("color = " + c);
- //ColorDrawable initialColor = new ColorDrawable(Color.parseColor(String.valueOf(button.getDrawingCacheBackgroundColor())));
- //Drawable initialColor = (Drawable) button.getBackground();
- //Button button1 = new Button(getContext());
- //System.out.println("button1.getSolidColor(); = " + button1.getSolidColor());
- //int colorId = initialColor.getColor();
- ColorDrawable lightRed = new ColorDrawable(Color.parseColor("#FFF97981"));
- ColorDrawable initialColor = new ColorDrawable(Color.LTGRAY);
- ColorDrawable[] color = {initialColor, lightRed};
- /*ColorDrawable[] color = {
- new ColorDrawable(Color.parseColor("#fa0707")),
- new ColorDrawable(Color.parseColor("#3507fa")),
- new ColorDrawable(Color.parseColor("#07faec")),
- new ColorDrawable(Color.parseColor("#faec07"))
- };*/
- TransitionDrawable trans = new TransitionDrawable(color);
- button.setBackground(trans);
- trans.startTransition(300); // duration 3 seconds
- //overridePendingTransition(R.anim.animation_enter, R.anim.animation_leave);
- /*int colorStart = button.getSolidColor();
- int colorEnd = 0xFFFF0000;
- ValueAnimator colorAnim = ObjectAnimator.ofInt(button,
- "backgroundColor", colorStart, colorEnd);
- colorAnim.setDuration(1000);
- colorAnim.setEvaluator(new ArgbEvaluator());
- colorAnim.setRepeatCount(1);
- colorAnim.setRepeatMode(ValueAnimator.REVERSE);
- colorAnim.start();*/
- //button.setBackgroundColor(Color.RED);
- /*if (btn1.getText().equals(wrongAnswer))
- btn1.setBackgroundColor(Color.RED);
- else
- btn2.setBackgroundColor(Color.RED);*/
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement