@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ButterKnife.bind(this);
    mContext = this;
    mUrl = getIntent().getStringExtra(EXTRA_URL);
    mTitle = getIntent().getStringExtra(EXTRA_TITLE);

    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    settings.setSupportZoom(true);
    mWebView.setWebChromeClient(new ChromeClient());
    mWebView.setWebViewClient(new LoveClient());

    mWebView.loadUrl(mUrl);

    mTextSwitcher.setFactory(
        () -> {
          TextView textView = new TextView(this);
          textView.setTextAppearance(this, R.style.WebTitle);
          textView.setSingleLine(true);
          textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
          textView.postDelayed(() -> textView.setSelected(true), 1738);
          return textView;
        });
    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);
    if (mTitle != null) setTitle(mTitle);
  }
  private void updateViews() {
    Step step = getCurrentStep();

    if (stepIndex + 1 >= steps.size()) {
      nextButton.setImageDrawable(buttonFinishIcon);
      nextButton.setContentDescription(getString(R.string.finish));
      step.updateView(true);
    } else {
      nextButton.setImageDrawable(buttonNextIcon);
      nextButton.setContentDescription(getString(R.string.next_step));
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    inputSwitcher.setDisplayedChild(stepIndex);
    errorSwitcher.setText("");
    detailsSwitcher.setText(step.getDetails(this));
    titleSwitcher.setText(step.getTitle(this));
    stepText.setText(getString(R.string.page_number, stepIndex + 1, steps.size()));

    stepText.setTextColor(detailsTextColor);

    updateProgressbar();
  }
  /**
   * onCreate之后调用,可以用来初始化view
   *
   * @param savedInstanceState the saved instance state
   */
  @Override
  public final void onCreateAfter(Bundle savedInstanceState) {
    parseIntent();

    enableJavascript();
    enableCaching();
    enableClient();
    enableAdjust();
    zoomedOut();
    // 网页标题
    mTextSwitcher.setFactory(
        () -> {
          TextView textView = new TextView(this);
          textView.setTextAppearance(this, R.style.WebTitle);
          textView.setSingleLine(true);
          textView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
          textView.postDelayed(() -> textView.setSelected(true), 1738);
          return textView;
        });
    mTextSwitcher.setInAnimation(this, android.R.anim.fade_in);
    mTextSwitcher.setOutAnimation(this, android.R.anim.fade_out);
    if (title != null) setTitle(title);

    if (mProgressBar != null)
      mProgressBar.setReachedBarColor(BaseApplication.color(R.color.colorPrimary));

    // 设置滑动监听
    mWebView.setOnScrollChangedCallback(
        (dx, dy, x, y) -> { // 滑动监听
        });

    onCreateAfterLater();
  }
  public void updateTabCountAndAnimate(int count) {
    if (mCount > count) {
      mTabsCount.setInAnimation(mSlideDownIn);
      mTabsCount.setOutAnimation(mSlideDownOut);
    } else if (mCount < count) {
      mTabsCount.setInAnimation(mSlideUpIn);
      mTabsCount.setOutAnimation(mSlideUpOut);
    } else {
      return;
    }

    mTabsCount.setText(String.valueOf(count));
    mCount = count;
    mTabs.setContentDescription(mContext.getString(R.string.num_tabs, count));

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView())
                .setTextColor(mContext.getResources().getColor(R.color.url_bar_text_highlight));
          }
        },
        mDuration);

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView())
                .setTextColor(mContext.getResources().getColor(R.color.tabs_counter_color));
          }
        },
        2 * mDuration);
  }
Beispiel #5
0
  // AnimationSet as;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    words = getResources().getStringArray(R.array.quotes);
    _handler = new Handler();

    _quote = (TextSwitcher) findViewById(R.id.quote_text);

    _quote.setFactory(
        new ViewFactory() {
          public View makeView() {
            TextView quote = new TextView(getApplicationContext());
            quote.setGravity(Gravity.CENTER);
            quote.setTextColor(color.GhostWhite);
            quote.setTextAppearance(getApplicationContext(), android.R.style.TextAppearance_Large);
            quote.setTypeface(null, Typeface.ITALIC);
            return quote;
          }
        });

    in = new AlphaAnimation(0.0f, 1.0f);
    in.setDuration(2000);

    out = new AlphaAnimation(1.0f, 0.0f);
    out.setDuration(2000);

    _quote.setInAnimation(in);
    _quote.setOutAnimation(out);

    _handler.postDelayed(_updateQuoteTask, 0);
  }
  /**
   * Substracts one point to the corresponding team score depending on the {@code callerView}.
   *
   * @param callerView The view that has called this method.
   * @since 6
   */
  public void substractScore(View callerView) {
    int teamScoreToSubstractId = -1;

    switch (callerView.getId()) {
      case R.id.trucoAnnotator_substractButtonTeam1:
        teamScoreToSubstractId = R.id.trucoAnnotator_scoreTeam1;
        break;
      case R.id.trucoAnnotator_substractButtonTeam2:
        teamScoreToSubstractId = R.id.trucoAnnotator_scoreTeam2;
        break;
    }

    if (teamScoreToSubstractId != -1) {
      TextSwitcher scoreToUpdate = (TextSwitcher) findViewById(teamScoreToSubstractId);
      String currentValueString = ((TextView) scoreToUpdate.getCurrentView()).getText().toString();

      int currentScore = 0;
      if (!currentValueString.equals("")) {
        currentScore = Integer.valueOf(currentValueString);
      }

      if (currentScore != Integer.parseInt(getText(R.string.defaultInitialGameScore).toString())) {
        int updatedScore = currentScore - GameKeys.TRUCO_INCREMENT;

        Log.i(LOG_TAG, "Updating score to: " + updatedScore);
        scoreToUpdate.setText(String.valueOf(updatedScore));

        if (updatedScore == GameKeys.TRUCO_MAX_SCORE_WITHOUT_WIN) {
          enableAllControls();
        }
      }
    }
  }
Beispiel #7
0
  private void initialiseTextSwitcher() {
    mSwitcher = (TextSwitcher) rootView.findViewById(R.id.textSwitcher);
    mSwitcher.setFactory(
        new ViewFactory() {
          public View makeView() {
            TextView myText = new TextView(getActivity());
            myText.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
            myText.setTextSize(28);
            myText.setTextColor(Color.BLACK);
            return myText;
          }
        });

    // Declare the in and out animations and initialize them
    Animation in = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
    Animation out = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out);
    mSwitcher.setInAnimation(in);
    mSwitcher.setOutAnimation(out);

    mSwitcher.setOnClickListener(myhandler1);

    /** ******************************************************** */

    // Create Inner Thread Class
    background =
        new Thread(
            new Runnable() {

              // After call for background.start this run method call
              public void run() {
                try {
                  while (true) {
                    handler.sendEmptyMessage(0);
                    SystemClock.sleep(2200);
                  }
                } catch (Throwable t) {
                }
              }

              // Define the Handler that receives messages from the thread and update the progress
              @SuppressLint("HandlerLeak")
              private final Handler handler =
                  new Handler() {

                    public void handleMessage(Message msg) {
                      doUpdate();
                    }
                  };
            });
    // Start Thread
    background.start(); // After call start method thread called run Method

    /** ******************************************************************************** */
  }
Beispiel #8
0
 private void doUpdate() {
   currentIndex++;
   if (currentIndex == messageCount) {
     currentIndex = 0;
   }
   mSwitcher.setText(textToShow.get(currentIndex));
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_input_form);

    loadTheme();

    findViews();

    steps = onCreateSteps();

    if (savedInstanceState != null) {
      setupData = savedInstanceState.getBundle(KEY_DATA);
      stepIndex = savedInstanceState.getInt(KEY_STEP_INDEX, 0);
    }

    setupTitle();
    setupInput();
    setupError();
    setupDetails();

    nextButton.setOnClickListener(nextButtonClickListener);
    errorSwitcher.setText("");
    updateStep();
  }
Beispiel #10
0
 public void run() {
   int num = words.length;
   Random r = new Random();
   int i = (r.nextInt(num));
   _quote.setText(String.valueOf(words[i]).trim());
   _handler.postDelayed(this, 6000);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.game);

    mQuestionImage = (ImageSwitcher) findViewById(R.id.ImageSwitcher_QuestionImage);
    mQuestionImage.setFactory(new MyImageSwitcherFactory());

    mQuestionText = (TextSwitcher) findViewById(R.id.TextSwitcher_QuestionText);
    mQuestionText.setFactory(new MyTextSwitcherFactory());

    mQuestions = new Hashtable<Integer, Question>(QUESTION_BATCH_SIZE);

    mGameSettings = getSharedPreferences(GAME_PREFERENCES, Context.MODE_PRIVATE);
    int staringQuestionNumber = mGameSettings.getInt(GAME_PREFERENCES_CURRENT_QUESTION, 0);
    if (staringQuestionNumber == 0) {
      Editor editor = mGameSettings.edit();
      editor.putInt(GAME_PREFERENCES_CURRENT_QUESTION, 1);
      editor.commit();
      staringQuestionNumber = 1;
    }
    downloader = new QuizTask();
    downloader.execute(TRIVIA_SERVER_QUESTIONS, staringQuestionNumber);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_single_input_form);

    loadTheme();

    sSteps = getSteps(this);
    sStepOptional = getOptionalSteps(this);

    findViews();

    if (savedInstanceState != null) {
      setupData = savedInstanceState.getBundle(KEY_DATA);
      mStepIndex = savedInstanceState.getInt(KEY_STEP_INDEX, 0);
    }

    setupTitle();
    setupInput();
    setupError();
    setupDetails();

    mNextButton.setOnClickListener(mOnNextButtonClickListener);
    mErrorSwitcher.setText("");

    Step step = getCurrentStep();
    if (step != null && step instanceof TextStep) {
      try {
        ((TextStep) step).getView().setOnEditorActionListener(mOnEnterPressListener);
      } catch (Exception e) {
      }
    }
    updateStep();
  }
 private void displayCurrentQuestion(int staringQuestionNumber) {
   if (mQuestions.containsKey(staringQuestionNumber)) {
     mQuestionText.setCurrentText(this.getQuestionText(staringQuestionNumber));
     mQuestionImage.setImageDrawable(this.getQuestionImageDrawable(staringQuestionNumber));
   } else {
     handNoQuestion();
   }
 }
  /**
   * Initializes the score TextSwitcher for the specified {@code textSwitcher}. It also sets the
   * {@code listener}.
   *
   * @param listener The listener which will update the text.
   */
  private void initializeTextSwitcher(
      final TextSwitcher textSwitcher, View.OnTouchListener listener) {
    textSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {
          @Override
          public View makeView() {
            TextView textView = new TextView(textSwitcher.getContext());
            textView.setTextSize(36);
            return textView;
          }
        });

    textSwitcher.setOnTouchListener(listener);
    textSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in));
    textSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));

    textSwitcher.setText(getText(R.string.defaultInitialGameScore));
  }
  /** 当没有问题时 */
  private void handNoQuestion() {
    mQuestionText.setText(getResources().getText(R.string.no_questions));
    mQuestionImage.setImageResource(R.drawable.noquestion);

    Button yesButton = (Button) findViewById(R.id.Button_Yes);
    yesButton.setEnabled(false);

    Button noButton = (Button) findViewById(R.id.Button_No);
    noButton.setEnabled(false);
  }
  private void setupError() {
    errorSwitcher.setInAnimation(getAnimation(android.R.anim.slide_in_left, true));
    errorSwitcher.setOutAnimation(getAnimation(android.R.anim.slide_out_right, false));

    errorSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {

          @Override
          public View makeView() {
            TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_error, null);
            if (view != null && errorTextColor != -1) {
              view.setTextColor(errorTextColor);
            }
            return view;
          }
        });

    errorSwitcher.setText("");
  }
  private void setupDetails() {
    detailsSwitcher.setInAnimation(getAnimation(R.anim.alpha_in, true));
    detailsSwitcher.setOutAnimation(getAnimation(R.anim.alpha_out, false));

    detailsSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {

          @Override
          public View makeView() {
            TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_details, null);
            if (view != null && detailsTextColor != -1) {
              view.setTextColor(detailsTextColor);
            }
            return view;
          }
        });

    detailsSwitcher.setText("");
  }
  private void setupTitle() {
    titleSwitcher.setInAnimation(getAnimation(R.anim.slide_in_to_bottom, true));
    titleSwitcher.setOutAnimation(getAnimation(R.anim.slide_out_to_top, false));

    titleSwitcher.setFactory(
        new ViewSwitcher.ViewFactory() {

          @Override
          public View makeView() {
            TextView view = (TextView) getLayoutInflater().inflate(R.layout.view_title, null);
            if (view != null) {
              view.setTextColor(titleTextColor);
            }
            return view;
          }
        });

    titleSwitcher.setText("");
  }
Beispiel #19
0
  private void initializeTextViews() {
    textViewQuestion = (TextView) findViewById(R.id.textViewQuestion);

    textViewNumberOfQuestionsLeft = (TextView) findViewById(R.id.textViewNumberOfQuestionsLeft);
    textViewQuestionLevel = (TextView) findViewById(R.id.textViewQuestionLevel);
    textViewLivesLeftValue = (TextView) findViewById(R.id.textViewLivesLeftValue);
    textViewTimesPlayedTitle = (TextView) findViewById(R.id.textViewTimesPlayedTitle);
    textViewGameScoreText = (TextView) findViewById(R.id.textViewGameScoreText);
    textViewHowManyTimesQuestionsBeenAsked =
        (TextView) findViewById(R.id.textViewHowManyTimesQuestionsBeenAsked);

    textSwitcherTime = (TextSwitcher) findViewById(R.id.textViewTime);

    textSwitcherTime.setFactory(this);

    Animation inAnimation = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
    Animation outAnimation = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);

    textSwitcherTime.setInAnimation(inAnimation);
    textSwitcherTime.setOutAnimation(outAnimation);
  }
  private void updateViews() {
    Step step = getCurrentStep();
    if (step == null) {
      if (mStepIndex >= stepsSize()) {
        hideSoftInput();
        onFormFinished(setupData);

        mStepIndex--; // reset stepIndex to last step
        finish();
        return;
      }
    }
    if (mStepIndex + 1 >= stepsSize()) {
      mNextButton.setImageDrawable(mButtonFinishIcon);
      step.updateView(true);
    } else {
      hideSoftInput();
      mNextButton.setImageDrawable(mButtonNextIcon);
      step.updateView(false);
    }

    step.restore(setupData);

    setTextFieldBackgroundDrawable();

    mInputSwitcher.setDisplayedChild(mStepIndex);
    mErrorSwitcher.setText("");
    mDetailsSwitcher.setText(step.getDetails());
    mTitleSwitcher.setText(step.getTitle());
    mStepText.setText(getString(R.string.page_number, mStepIndex + 1, stepsSize()));

    mStepText.setTextColor(mDetailsTextColor);
    if (step instanceof TextStep) System.out.println(step.getView().requestFocus());

    updateProgressbar();
  }
Beispiel #21
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   textSwitcher = (TextSwitcher) findViewById(R.id.textSwitcher);
   textSwitcher.setFactory(
       new ViewSwitcher.ViewFactory() {
         public View makeView() {
           TextView tv = new TextView(MainActivity.this);
           tv.setTextSize(40);
           tv.setTextColor(Color.MAGENTA);
           return tv;
         }
       });
   // 调用next方法显示下一个字符串
   next(null);
 }
Beispiel #22
0
  public void setValueText(String valueText) {
    if (null == valueText) {
      return;
    }

    mSwitcher.setText(valueText);
    /*if(!TextUtils.isDigitsOnly(valueText)){
    	mSwitcher.setText(valueText);
    	return;
    }
    final int number = Integer.valueOf(valueText);
    if(null != mSwitcher && !TextUtils.isEmpty(valueText)){
           new AsyncTask<Void, Void, Void>(){

    		private int mCounter;

    		@Override
    		protected Void doInBackground(Void... params) {
               	for (int i = 0; i <= number; i+=100) {
               		try {
               			mCounter+=100;
    					Thread.sleep(0, 300000);
               			publishProgress();
    				} catch (InterruptedException e) {
    					e.printStackTrace();
    				}
    			}
    			return null;
    		}

           	@Override
           	protected void onProgressUpdate(Void... values) {
       			mSwitcher.setText(String.valueOf(mCounter));
           		super.onProgressUpdate(values);
           	}

           	@Override
           	protected void onPostExecute(Void result) {
           		mSwitcher.setText(String.valueOf(mCounter));
           		super.onPostExecute(result);
           	}

           }.execute();
    }*/
  }
  protected void nextStep() {
    Step step = getCurrentStep();
    boolean checkStep = checkStep();
    if (!checkStep) {
      if (!error) {
        error = true;
        errorSwitcher.setText(step.getError(this));
      }
    } else {
      error = false;
    }
    if (error) {
      return;
    }
    setupData = step.save(setupData);

    stepIndex++;
    updateStep();
  }
Beispiel #24
0
  private void init(Context context, AttributeSet attrs, int defStyle) {
    mContext = context;

    LayoutInflater.from(context).inflate(R.layout.view_text_number, this, true);
    /*		if(isInEditMode()){
    	return;
    }*/

    mSwitcher = (TextSwitcher) findViewById(R.id.switcher);
    mSwitcher.setFactory(
        new ViewFactory() {

          @Override
          public View makeView() {

            LayoutInflater inflater = LayoutInflater.from(mContext);
            TextPlus textView = (TextPlus) inflater.inflate(R.layout.view_text_plus, null);
            textView.setPrefix(mContext.getString(R.string.rupee), 0);
            return textView;
          }
        });
  }
 private void handleAnswerAndShowNextQuestion(boolean bAnswer) {
   int CurScore = mGameSettings.getInt(GAME_PREFERENCES_SCORE, 0);
   int nextQuestionNumber = mGameSettings.getInt(GAME_PREFERENCES_CURRENT_QUESTION, 1) + 1;
   Editor editor = mGameSettings.edit();
   editor.putInt(GAME_PREFERENCES_CURRENT_QUESTION, nextQuestionNumber);
   if (bAnswer) editor.putInt(GAME_PREFERENCES_SCORE, CurScore + 1);
   editor.commit();
   if ((mQuestions.containsKey(nextQuestionNumber)) == false) {
     try {
       downloader = new QuizTask();
       downloader.execute(TRIVIA_SERVER_QUESTIONS, nextQuestionNumber);
     } catch (Exception e) {
       Log.e(DEBUG_TAG, "Loading initial question batch failed", e);
     }
   }
   if (mQuestions.containsKey(nextQuestionNumber)) {
     mQuestionText.setCurrentText(this.getQuestionText(nextQuestionNumber));
     mQuestionImage.setImageDrawable(this.getQuestionImageDrawable(nextQuestionNumber));
   } else {
     handNoQuestion();
   }
 }
  public void updateTabs(int count) {
    if (mCount > count) {
      mTabsCount.setInAnimation(mSlideDownIn);
      mTabsCount.setOutAnimation(mSlideDownOut);
    } else if (mCount < count) {
      mTabsCount.setInAnimation(mSlideUpIn);
      mTabsCount.setOutAnimation(mSlideUpOut);
    }

    if (count > 1) mTabs.setImageLevel(count);
    else mTabs.setImageLevel(0);

    mTabsCount.setVisibility(View.VISIBLE);
    mTabsCount.setText(String.valueOf(count));
    mCount = count;

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            ((TextView) mTabsCount.getCurrentView()).setTextColor(mColor);
          }
        },
        mDuration);

    mHandler.postDelayed(
        new Runnable() {
          public void run() {
            if (Tabs.getInstance().getCount() == 1) {
              mTabs.setImageLevel(1);
              mTabsCount.setVisibility(View.GONE);
              ((TextView) mTabsCount.getCurrentView()).setTextColor(mCounterColor);
            } else {
              ((TextView) mTabsCount.getCurrentView()).setTextColor(mCounterColor);
            }
          }
        },
        2 * mDuration);
  }
 @Override
 public void setTitle(CharSequence title) {
   super.setTitle(title);
   mTextSwitcher.setText(title);
 }
  @Override
  public void onAttachedToWindow() {
    super.onAttachedToWindow();

    if (mAutoUpdateTheme) mTheme.addListener(this);
  }
  @Override
  public void onDetachedFromWindow() {
    super.onDetachedFromWindow();

    if (mAutoUpdateTheme) mTheme.removeListener(this);
  }
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   super.onLayout(changed, left, top, right, bottom);
   onLightweightThemeChanged();
 }