Example #1
0
 private void tintButton(int showcaseColor, boolean tintButton) {
   if (tintButton) {
     mEndButton.getBackground().setColorFilter(showcaseColor, PorterDuff.Mode.MULTIPLY);
   } else {
     mEndButton.getBackground().setColorFilter(HOLO_BLUE, PorterDuff.Mode.MULTIPLY);
   }
 }
Example #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_page);

    Bundle extras = getIntent().getExtras();
    final int teamId = extras.getInt("Team ID");
    Team team = db.getTeam(teamId);
    String teamName = team.getTeamName();

    TextView display = (TextView) findViewById(R.id.selected_team);
    display.setText(teamName);

    String[] teamRoster = getRoster(teamId); // db.getPlayerNames();

    final Button backButton = (Button) findViewById(R.id.go_back);
    backButton.getBackground().setColorFilter(new LightingColorFilter(0xFF000000, 0xFFAA330F));

    backButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent i = new Intent(PlayerPage.this, TeamPage.class);
            finish();
            startActivity(i);
          }
        });

    final Button startButton = (Button) findViewById(R.id.create_player);
    startButton.getBackground().setColorFilter(new LightingColorFilter(0xFF000000, 0xFF29ABDD));

    listView = (ListView) findViewById(R.id.existing_players); //

    startButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d("Check", "to intent");
            Intent i = new Intent(PlayerPage.this, CreatePlayer.class);
            i.putExtra("Team ID", teamId);
            finish();
            startActivity(i);
          }
        });

    ArrayAdapter<String> adapter =
        new ArrayAdapter<String>(
            this,
            android.R.layout.simple_list_item_1,
            android.R.id.text1,
            teamRoster); // (String[]) players); //

    listView.setAdapter(adapter);
    registerForContextMenu(listView); // attachs context menu to listview
  }
 private void updateList() {
   // Log.v( TopoDroidApp.TAG, "ItemPickerDialog ... updateList type " + mItemType );
   switch (mItemType) {
     case DrawingActivity.SYMBOL_POINT:
       // if ( TDSetting.mLevelOverBasic )
       {
         mAdapter = mPointAdapter;
         mBTpoint
             .getBackground()
             .setColorFilter(Color.parseColor("#ccccff"), PorterDuff.Mode.LIGHTEN);
         mBTline
             .getBackground()
             .setColorFilter(Color.parseColor("#cccccc"), PorterDuff.Mode.DARKEN);
         mBTarea
             .getBackground()
             .setColorFilter(Color.parseColor("#cccccc"), PorterDuff.Mode.DARKEN);
         mSeekBar.setVisibility(View.VISIBLE);
         setSeekBarProgress();
       }
       break;
     case DrawingActivity.SYMBOL_LINE:
       mAdapter = mLineAdapter;
       mBTpoint
           .getBackground()
           .setColorFilter(Color.parseColor("#cccccc"), PorterDuff.Mode.DARKEN);
       mBTline
           .getBackground()
           .setColorFilter(Color.parseColor("#ccccff"), PorterDuff.Mode.LIGHTEN);
       mBTarea.getBackground().setColorFilter(Color.parseColor("#cccccc"), PorterDuff.Mode.DARKEN);
       mSeekBar.setVisibility(View.INVISIBLE);
       break;
     case DrawingActivity.SYMBOL_AREA:
       // if ( TDSetting.mLevelOverBasic )
       {
         mAdapter = mAreaAdapter;
         mBTpoint
             .getBackground()
             .setColorFilter(Color.parseColor("#cccccc"), PorterDuff.Mode.DARKEN);
         mBTline
             .getBackground()
             .setColorFilter(Color.parseColor("#cccccc"), PorterDuff.Mode.DARKEN);
         mBTarea
             .getBackground()
             .setColorFilter(Color.parseColor("#ccccff"), PorterDuff.Mode.LIGHTEN);
         mSeekBar.setVisibility(View.INVISIBLE);
       }
       break;
   }
   if (mAdapter != null) {
     if (mList != null) {
       mList.setAdapter(mAdapter);
       mList.invalidate();
     } else if (mGrid != null) {
       mGrid.setAdapter(mAdapter);
       mGrid.invalidate();
     }
   }
 }
        @Override
        public void handleMessage(Message msg) {
          dead = true;
          skill1Button.setEnabled(false);
          skill1Button.setTextColor(Color.GRAY);
          // skill1Button.setBackgroundResource(R.drawable.disabled_button);
          skill1Button.getBackground().setAlpha(50);

          skill2Button.setEnabled(false);
          skill2Button.setTextColor(Color.GRAY);
          // skill2Button.setBackgroundResource(R.drawable.disabled_button);
          skill2Button.getBackground().setAlpha(50);
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_agregar_indicacion_medica);

    campoIndicacion = (EditText) findViewById(R.id.campoIndicacion);

    botonGuardarIndicacion = (Button) findViewById(R.id.botonGuardarIndicacion);
    botonGuardarIndicacion.getBackground().setColorFilter(0xFF00A1E1, PorterDuff.Mode.MULTIPLY);
    botonGuardarIndicacion.setOnClickListener(this);

    botonVolver = (Button) findViewById(R.id.botonVolver);
    botonVolver.getBackground().setColorFilter(0xFF00A1E1, PorterDuff.Mode.MULTIPLY);
    botonVolver.setOnClickListener(this);
  }
Example #6
0
  /**
   * Creates a new ButtonBase component.
   *
   * @param container container, component will be placed in
   */
  public ButtonBase(ComponentContainer container) {
    super(container);
    view = new android.widget.Button(container.$context());

    // Save the default values in case the user wants them back later.
    defaultButtonDrawable = view.getBackground();
    defaultColorStateList = view.getTextColors();

    // Adds the component to its designated container
    container.$add(this);

    // Listen to clicks and focus changes
    view.setOnClickListener(this);
    view.setOnFocusChangeListener(this);
    view.setOnLongClickListener(this);
    view.setOnTouchListener(this);

    // Default property values
    TextAlignment(Component.ALIGNMENT_CENTER);
    // BackgroundColor and Image are dangerous properties:
    // Once either of them is set, the 3D bevel effect for the button is
    // irretrievable, except by reloading defaultButtonDrawable, defined above.
    BackgroundColor(Component.COLOR_DEFAULT);
    Image("");
    Enabled(true);
    fontTypeface = Component.TYPEFACE_DEFAULT;
    TextViewUtil.setFontTypeface(view, fontTypeface, bold, italic);
    FontSize(Component.FONT_DEFAULT_SIZE);
    Text("");
    TextColor(Component.COLOR_DEFAULT);
    Shape(Component.BUTTON_SHAPE_DEFAULT);
  }
  public void play() {

    // Hide the finish button
    finishButton.setVisibility(View.INVISIBLE);

    // Changes the text and the colour of the button
    startButton.setText("Pause");
    startButton.getBackground().setColorFilter(Color.YELLOW, PorterDuff.Mode.MULTIPLY);

    // Resume time count from previous time.
    myChrono.setBase(SystemClock.elapsedRealtime() + timeWhenPaused);
    myChrono.start();

    // Only drop a green marker at the beginning of the activity
    if (firstTime == true) {

      // Drop Green marker at start position
      map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      LatLng startLocation = new LatLng(latitude, longitude);
      routePoints.add(startLocation);
      polyline.add(startLocation);
      CameraUpdate update = CameraUpdateFactory.newLatLngZoom(startLocation, 17);
      map.addMarker(
          new MarkerOptions()
              .position(startLocation)
              .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
      map.animateCamera(update);
      firstTime = false;
    }
  }
  public void pause() {

    // Show the finish button
    finishButton.setVisibility(View.VISIBLE);

    // Changes the text and the colour of the button
    startButton.setText("Resume");
    startButton.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.MULTIPLY);

    // Save the current time
    timeWhenPaused = myChrono.getBase() - SystemClock.elapsedRealtime();
    myChrono.stop();

    // Set a yellow marker on the current paused location
    LatLng pauseLocation = new LatLng(latitude, longitude);
    map.addMarker(
        new MarkerOptions()
            .position(pauseLocation)
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)));

    // Zoom out to fit route points on the map.
    // This shows the user the total distance travelled on the map
    int last = routePoints.size();
    if (last >= 2) {

      LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
      for (int i = 0; i < last; i++) {
        boundsBuilder.include(routePoints.get(i));
      }

      LatLngBounds bounds = boundsBuilder.build();
      map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 180));
    } else ;
  }
 @Override
 public void handleMessage(Message msg) {
   dead = false;
   if (skill1CooledDown) {
     skill1Button.setEnabled(true);
     skill1Button.setTextColor(Color.WHITE);
     // skill1Button.setBackgroundResource(SkillDef.getButtonById(skill1));
     skill1Button.getBackground().setAlpha(180);
   }
   if (skill2CooledDown) {
     skill2Button.setEnabled(true);
     skill2Button.setTextColor(Color.WHITE);
     // skill2Button.setBackgroundResource(SkillDef.getButtonById(skill2));
     skill2Button.getBackground().setAlpha(180);
   }
 }
  @Override
  public void populateView(Displayable displayable) {
    HeaderRow row = (HeaderRow) displayable;
    title.setText(row.getLabel());
    if (row.isHasMore()) {
      more.setVisibility(View.VISIBLE);
      if (storeName == null || TextUtils.isEmpty(storeName)) {
        if (storeId == 0) {
          more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme));
          moreLayout.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme));
        } else {
          more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme, storeId));
          moreLayout.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeId));
        }
      } else {
        if (storeId == 0) {
          more.setOnClickListener(new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName));
          moreLayout.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName));
        } else {
          more.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName, storeId));
          moreLayout.setOnClickListener(
              new BaseAdapter.IHasMoreOnClickListener(row, theme, storeName, storeId));
        }
      }
    } else {
      more.setVisibility(View.GONE);
      moreLayout.setClickable(false);
      moreLayout.setFocusable(false);
    }

    if (theme != null) {
      @ColorInt int color = itemView.getContext().getResources().getColor(theme.getStoreHeader());
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        more.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);
      } else {

        // put this in Utils when you need to tint a Button background
        Drawable wrapDrawable = DrawableCompat.wrap(more.getBackground());
        DrawableCompat.setTint(
            wrapDrawable, itemView.getContext().getResources().getColor(theme.getStoreHeader()));
        more.setBackgroundDrawable(DrawableCompat.unwrap(wrapDrawable));
      }
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!isGooglePlayServicesAvailable()) {
      finish();
    }

    // Create view
    setContentView(R.layout.activity_home_page);

    // Spinner
    spinner = (ProgressBar) findViewById(R.id.progressBar);
    spinner.bringToFront();
    spinner.setVisibility(View.GONE);

    // Add Maps
    mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    mapsActivity = new MapsActivity(getBaseContext(), mapFragment, this);

    // Get Autocomplete textview
    autoCompView = (AutoCompleteTextView) findViewById(R.id.destination);
    autoCompView.setAdapter(new GooglePlacesAutocompleteAdapter(this, R.layout.list_item));
    autoCompView.setOnItemClickListener(this);

    // Add background to Done button
    submitUpdate = (Button) findViewById(R.id.submitUpdate);
    submitUpdate.getBackground().setColorFilter(0xFF000000, PorterDuff.Mode.MULTIPLY);

    // Set Date TimePicker
    setDateTimePicker();
    // Call the method to call the Maps activity
    // Set the drawer
    setupDrawer();
    addDrawerItems();
    // Get hidden Panel
    hiddenPanel = findViewById(R.id.hidden_panel);

    // Call to get API esults
    apiResults = new GetAPIResults(getBaseContext(), mapFragment, this);

    // Check if there is a savedInstance
    if (savedInstanceState != null && savedInstanceState.getString("parking_listings") != null) {
      saved = true;
      JSONArray parking_listings_array = null;

      try {
        latitude = savedInstanceState.getDouble("lat");
        longitude = savedInstanceState.getDouble("lng");
        parking_listings = savedInstanceState.getString("parking_listings");
        parking_listings_array = new JSONArray(parking_listings);
        mapsActivity.addMapsOnMarker(parking_listings_array, latitude, longitude);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    } else {
      mMap = mapFragment.getMap();
      getCurrentLocationOfUser();
    }
  }
 private void resetBorders() {
   for (int i = 0; i < ids.length; i++) {
     final Button button = mColorButton[i];
     GradientDrawable sd = ((GradientDrawable) button.getBackground());
     sd.setColor(mBasColors[i]);
     sd.setStroke(3, (mSelectedColorButton == i) ? mSelected : mTransparent);
   }
 }
Example #13
0
 public void showZeit(View view) {
   // Do something in response to button
   btnZeit = (Button) findViewById(synteam.SS16.code.synword.R.id.btnZeit);
   btnZeit.getBackground().setAlpha(128);
   Intent intent = new Intent(this, tsloadscreenActivity.class);
   intent.putExtra("sprache", sprache);
   startActivity(intent);
   finish();
 }
Example #14
0
  public void selectOffButton(Button button) {
    TransitionDrawable drawable = (TransitionDrawable) button.getBackground();
    drawable.reverseTransition(100);

    ObjectAnimator colorAnim = ObjectAnimator.ofInt(button, "textColor", Color.BLACK, Color.WHITE);
    colorAnim.setDuration(100);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.start();
  }
  /**
   * Verifica se o usuário preenchou corretamento de acordo com o grupo de processos escolhido na
   * tela principal.
   */
  private void checar() {
    int count = 0;
    int total = params.getInt("Total");
    boolean errado = false;
    String tag = "";

    LinearLayout l = (LinearLayout) findViewById(R.id.direita);
    ArrayList<View> listViews = l.getTouchables();
    Button botaoC;
    for (View bt : listViews) {
      botaoC = (Button) bt;
      tag = botaoC.getTag().toString().trim();

      if (botaoC.getText().equals(getResources().getString(R.string.solicitar_mudancas))
          && (params.getString("Tipo").equals("C") || params.getString("Tipo").equals("D"))) {
        count++;
      } else if (tag.equals(params.getString("Tipo"))) {
        count++;
      } else {
        count = 0;
        errado = true;
        corPadrao = botaoC.getBackground();
        botaoC.setTextColor(getResources().getColor(R.color.cor_errado));
      }
    }

    if (errado) {
      Toast.makeText(
              DiagramaParcial.this,
              getResources().getString(R.string.opcoes_erradas),
              Toast.LENGTH_SHORT)
          .show();
      correto = false;
      invalidateOptionsMenu();
      return;
    }

    if (count == total) {
      Toast.makeText(
              DiagramaParcial.this,
              getResources().getString(R.string.opcoes_corretas),
              Toast.LENGTH_SHORT)
          .show();
      correto = true;
      invalidateOptionsMenu();
    } else {
      Toast.makeText(
              DiagramaParcial.this,
              getResources().getString(R.string.opcoes_faltando),
              Toast.LENGTH_SHORT)
          .show();
      correto = false;
      invalidateOptionsMenu();
    }
  }
 @Override
 public void handleMessage(Message msg) {
   if (msg.what == 1) {
     if (!dead) {
       skill1Button.setEnabled(true);
       skill1Button.setTextColor(Color.WHITE);
       // skill1Button.setBackgroundResource(SkillDef.getButtonById(skill1));
       skill1Button.getBackground().setAlpha(180);
     }
     skill1CooledDown = true;
   } else if (msg.what == 2) {
     if (!dead) {
       skill2Button.setEnabled(true);
       skill2Button.setTextColor(Color.GRAY);
       // skill2Button.setBackgroundResource(SkillDef.getButtonById(skill2));
       skill2Button.getBackground().setAlpha(180);
     }
     skill2CooledDown = true;
   }
 }
  private void assignViews() {
    editTextDefaultCode = (EditText) getView().findViewById(R.id.editText_defaultCode);
    ccp = (CountryCodePicker) getView().findViewById(R.id.ccp);
    buttonSetNewDefaultCode = (Button) getView().findViewById(R.id.button_setDefault);
    buttonResetToDefault = (Button) getView().findViewById(R.id.button_resetToDefault);

    buttonNext = (Button) getView().findViewById(R.id.button_next);
    buttonNext
        .getBackground()
        .setColorFilter(
            getActivity().getResources().getColor(R.color.colorPrimary), PorterDuff.Mode.MULTIPLY);
  }
Example #18
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ParseAnalytics.trackEvent("Help");

    setContentView(R.layout.help_layout);
    Button b = (Button) findViewById(R.id.bAnswerOne);
    b.getBackground().setColorFilter(new LightingColorFilter(0xFF00D500, 0x00000000));
    b = (Button) findViewById(R.id.bAnswerTwo);
    b.getBackground().setColorFilter(new LightingColorFilter(0xFF00D500, 0x00000000));
    b = (Button) findViewById(R.id.bAnswerThree);
    b.getBackground().setColorFilter(new LightingColorFilter(0xFF00D500, 0x00000000));
    findViewById(R.id.bTweetMe)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent tIntent = new Intent(Intent.ACTION_VIEW);
                tIntent.setData(Uri.parse("http://twitter.com/jessesapps"));
                startActivity(tIntent);
              }
            });
    findViewById(R.id.bEmailMe)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                // TODO Auto-generated method stub
                String[] address = {"*****@*****.**"};
                Intent eIntent = new Intent(Intent.ACTION_SENDTO);
                eIntent.setType("*/*");
                eIntent.setData(Uri.parse("mailto:"));
                eIntent.putExtra(Intent.EXTRA_EMAIL, address);
                eIntent.putExtra(Intent.EXTRA_SUBJECT, "Bubble Match Madness");
                startActivity(eIntent);
              }
            });
  }
Example #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bar);
    buttonListener = new PostButtonListener();
    b_prePage = (Button) findViewById(R.id.prePage_thread);
    b_reply = (Button) findViewById(R.id.refresh);
    b_reply.setText("回复");

    b_nextPage = (Button) findViewById(R.id.nextPage_thread);
    b_prePage.setBackgroundColor(Color.parseColor("#4f6495ED"));
    b_nextPage.setBackgroundColor(Color.parseColor("#4f6495ED"));
    b_reply.setBackgroundColor(Color.parseColor("#4f649511"));
    b_reply.setOnClickListener(buttonListener);
    b_prePage.setOnClickListener(buttonListener);
    b_nextPage.setOnClickListener(buttonListener);
    contextContainer = (ScrollView) findViewById(R.id.contentScroll);
    b_prePage.getBackground().setAlpha(40);
    b_nextPage.getBackground().setAlpha(40);
    b_reply.getBackground().setAlpha(40);
    baiduUtil = BaiduUtil.getInstance();
    Intent intent = getIntent();
    index_selected_bar = intent.getIntExtra(SELECTED_BAR_INDEX, 0);
    index_selected_thread = intent.getIntExtra(SELECTED_THREAD_INDEX, 0);
    bar = baiduUtil.getLikeBars().get(index_selected_bar);
    postListener = new PostListener();
    Resources res = getResources();
    Integer index_Bar = intent.getIntExtra(SELECTED_BAR_INDEX, 0);

    List<PostThread> threads = bar.getPostThreads();
    selected_thread = threads.get(index_selected_thread);

    setTitle(selected_thread.getTitle());

    displayPosts(selected_thread);
  }
Example #20
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   radioGroup = (RadioGroup) findViewById(R.id.radioGroup);
   radioGroup.setOnCheckedChangeListener(new DisposeRadioButton());
   rbBin = (RadioButton) findViewById(R.id.rbBin);
   rbOct = (RadioButton) findViewById(R.id.rbOct);
   rbDec = (RadioButton) findViewById(R.id.rbDec);
   rbHex = (RadioButton) findViewById(R.id.rbHex);
   etInput = (EditText) findViewById(R.id.etInput);
   btnBin = (Button) findViewById(R.id.btnBin);
   btnBin.getBackground().setAlpha(150);
   btnOct = (Button) findViewById(R.id.btnOct);
   btnOct.getBackground().setAlpha(150);
   btnDec = (Button) findViewById(R.id.btnDec);
   btnDec.getBackground().setAlpha(150);
   btnHex = (Button) findViewById(R.id.btnHex);
   btnHex.getBackground().setAlpha(150);
   btnBin.setOnClickListener(new btnBinListener());
   btnOct.setOnClickListener(new btnOctListener());
   btnDec.setOnClickListener(new btnDecListener());
   btnHex.setOnClickListener(new btnHexListener());
 }
  public void testColorNewColorButtonChangesStandard() {
    int numberOfColorsToTest = 20;

    assertTrue("Waiting for DrawingSurface", mSolo.waitForView(DrawingSurface.class, 1, TIMEOUT));
    mSolo.clickOnView(mButtonTopColor);
    mSolo.sleep(COLOR_PICKER_DIALOGUE_APPERANCE_DELAY);

    TypedArray presetColors = getActivity().getResources().obtainTypedArray(R.array.preset_colors);

    numberOfColorsToTest = Math.min(numberOfColorsToTest, presetColors.length());

    for (int counterColors = 0; counterColors < numberOfColorsToTest; counterColors++) {
      Log.d(PaintroidApplication.TAG, "test color # " + counterColors);
      Button colorButton = mSolo.getButton(counterColors);

      if (!(colorButton.getParent() instanceof TableRow)) {
        Log.d(
            PaintroidApplication.TAG, "button parent is no table row: " + colorButton.getParent());
        continue;
      }

      mSolo.clickOnButton(counterColors);
      mSolo.sleep(200);
      int colorColor = presetColors.getColor(counterColors, 0);

      String buttonNewColorName = getActivity().getResources().getString(R.string.done);
      Button button = mSolo.getButton(buttonNewColorName);
      Drawable drawable = button.getBackground();
      int buttonTextColor = button.getCurrentTextColor();

      Bitmap bitmap = drawableToBitmap(drawable, button.getWidth(), button.getHeight());
      int buttonColor = bitmap.getPixel(1, 1);
      assertEquals("New Color button has unexpected color", colorColor, buttonColor);
      assertTrue(
          "Button textcolor and backgroundcolor ar the same", buttonColor != buttonTextColor);
      assertTrue(
          "Unexpected text color in butten text",
          (buttonTextColor == Color.BLACK || buttonTextColor == Color.WHITE));
      assertTrue(
          "Color not set yet", colorColor == mTopBar.getCurrentTool().getDrawPaint().getColor());
      bitmap.recycle();
      bitmap = null;
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tela_jogo);
    btna = (Button) findViewById(R.id.a);
    btnb = (Button) findViewById(R.id.b);
    btnc = (Button) findViewById(R.id.c);
    btnd = (Button) findViewById(R.id.d);
    btne = (Button) findViewById(R.id.e);
    btnf = (Button) findViewById(R.id.f);
    btng = (Button) findViewById(R.id.g);
    btnh = (Button) findViewById(R.id.h);
    btni = (Button) findViewById(R.id.i);
    btna.setOnClickListener(buttona);
    btnb.setOnClickListener(buttonb);
    btnc.setOnClickListener(buttonc);
    btnd.setOnClickListener(buttond);
    btne.setOnClickListener(buttone);
    btnf.setOnClickListener(buttonf);
    btng.setOnClickListener(buttong);
    btnh.setOnClickListener(buttonh);
    btni.setOnClickListener(buttoni);
    buttonBackground = btna.getBackground();
    jogando = (TextView) findViewById(R.id.Jogadores);
    limpaMatriz();
    flagGanhador = 0;
    matrizCheia = 0;

    // Recebe nome do jogador local
    Intent receberMensagem = getIntent();
    nomeJogador = receberMensagem.getStringExtra(TelaNome.MENSAGEM);

    // instancia o adaptador bluetooth do dispositivo
    myBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if (myBluetoothAdapter == null) {
      Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
      finish();
      return;
    }
  }
  /**
   * The system calls this to get the DialogFragment's layout, regardless of whether it's being
   * displayed as a dialog or an embedded fragment.
   */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout to use as dialog or embedded fragment
    View view = inflater.inflate(R.layout.fragment_quiz_result, container, false);

    mAnswers = getArguments().getStringArrayList(EXTRA_KEY_ANSWERS);
    mCorrectAnswerId = getArguments().getInt(EXTRA_KEY_CORRECT_ANSWER_ID);

    int[] CLICKABLES =
        new int[] {
          R.id.fragment_quiz_result_btn_answer1,
          R.id.fragment_quiz_result_btn_answer2,
          R.id.fragment_quiz_result_btn_answer3,
          R.id.fragment_quiz_result_btn_answer4
        };

    for (int i = 0; i < CLICKABLES.length; i++) {
      int id = CLICKABLES[i];

      Button btnAnswer = (Button) view.findViewById(id);
      btnAnswer.setOnClickListener(this);
      btnAnswer.setText(mAnswers.get(i));
      if (i == mCorrectAnswerId) {
        btnAnswer.getBackground().setColorFilter(0xFF8DCF67, PorterDuff.Mode.MULTIPLY);
      }
    }

    setCommandDescriptionForTextView(view, R.id.fragment_quiz_result_tv_answer1, mAnswers.get(0));
    setCommandDescriptionForTextView(view, R.id.fragment_quiz_result_tv_answer2, mAnswers.get(1));
    setCommandDescriptionForTextView(view, R.id.fragment_quiz_result_tv_answer3, mAnswers.get(2));
    setCommandDescriptionForTextView(view, R.id.fragment_quiz_result_tv_answer4, mAnswers.get(3));

    setQuestionTextView(
        view, R.id.fragment_quiz_result_tv_question, mAnswers.get(mCorrectAnswerId));

    return view;
  }
  /** Initialize the main layout of the game view, including buttons, MUD, etc. */
  private void initLayout() {

    this.setContentView(R.layout.game_layout);

    mGLView = (GLSurfaceView) this.findViewById(R.id.game_activity_gl_surface_view);

    // here we need to wait for the init data to be sent from the server to create the render
    // and start drawing
    while (!Client.isGameInited()) {
      try {
        Thread.sleep(100);
      } catch (Exception e) {
      }
    }

    self.renderer = new GameRenderer(this);
    mGLView.setRenderer(self.renderer);
    GameRenderer.startRendering();

    int ballSelected = self.getIntent().getIntExtra("ballSelected", BallCraft.Ball.WOOD_BALL);
    final int[] skills = BallDef.getSkillsById(ballSelected);
    skill1 = skills[0];
    skill2 = skills[1];

    skill1Button = (Button) this.findViewById(R.id.game_activity_skill_1_button);
    skill1Button.setTypeface(MyApplication.getFont());
    skill1Button.setBackgroundResource(SkillDef.getButtonById(skill1));
    skill1Button.getBackground().setAlpha(180);
    skill1Button.setText(SkillDef.getSkillNameById(skill1));
    skill1Button.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Client.castSkill(Skill.getSkill(skill1));
            skill1Button.setEnabled(false);
            skill1Button.setTextColor(Color.GRAY);
            skill1Button.getBackground().setAlpha(50);
            skill1CooledDown = false;
            Message msg = new Message();
            msg.what = 1;
            skillCoolDownHandler.sendMessageDelayed(msg, SkillDef.getCoolDownTimeById(skill1));
          }
        });

    skill2Button = (Button) this.findViewById(R.id.game_activity_skill_2_button);
    skill2Button.setTypeface(MyApplication.getFont());
    skill2Button.setBackgroundResource(SkillDef.getButtonById(skill2));
    skill2Button.getBackground().setAlpha(180);
    skill2Button.setText(SkillDef.getSkillNameById(skill2));
    skill2Button.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            Client.castSkill(Skill.getSkill(skill2));
            skill2Button.setEnabled(false);
            skill2Button.setTextColor(Color.GRAY);
            skill2Button.getBackground().setAlpha(50);
            skill2CooledDown = false;
            Message msg = new Message();
            msg.what = 2;
            skillCoolDownHandler.sendMessageDelayed(msg, SkillDef.getCoolDownTimeById(skill2));
          }
        });

    loseView = (TextView) this.findViewById(R.id.game_activity_lose_text);
    loseView.setTypeface(MyApplication.getFont());
    loseView.setVisibility(View.INVISIBLE);

    remainingTimeView = (TextView) this.findViewById(R.id.game_activity_remaining_time_view);
    remainingTimeView.setTypeface(MyApplication.getFont());

    scoreView = (TextView) this.findViewById(R.id.game_activity_score_view);
    scoreView.setTypeface(MyApplication.getFont());
    scoreView.setText("0 : 0");
    scoreView.setTextColor(Color.YELLOW);

    backScreen = (RelativeLayout) this.findViewById(R.id.game_activity_menu);
    backScreen.setVisibility(View.INVISIBLE);

    resumeButton = (TextView) this.findViewById(R.id.game_activity_resume_button);
    resumeButton.setTypeface(MyApplication.getFont());
    resumeButton.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            self.onBackPressed();
          }
        });

    exitButton = (TextView) this.findViewById(R.id.game_activity_exit_button);
    exitButton.setTypeface(MyApplication.getFont());
    exitButton.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            endGame();
          }
        });
  }
Example #25
0
  /*
   * override of android app create method
   * @see android.app.Activity#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // initialize the location and phone state listeners
    locationListener = new mylocationlistener();
    phoneStateListener = new MyPhoneStateListener();
    phoneStateManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    final Button btStart = (Button) this.findViewById(R.id.Button1);
    final Button btStop = (Button) this.findViewById(R.id.Button2);
    tv = (TextView) this.findViewById(R.id.textView1);

    // set text view fonts and colors
    tv.setTypeface(null, Typeface.BOLD);
    tv.setBackgroundColor(Color.BLACK);
    tv.setTextSize(20);
    tv.setTextColor(Color.WHITE);
    // set buttons initial state and shading
    btStop.setEnabled(false);
    btStart.setEnabled(true);
    btStart.getBackground().setAlpha(255);
    btStop.getBackground().setAlpha(127);
    addText("Server:" + POST_URL);
    // anonymous class method for Start button
    btStart.setOnClickListener(
        new OnClickListener() {
          public void onClick(View view) {
            btStart.setEnabled(false);
            btStop.setEnabled(true);

            btStart.getBackground().setAlpha(127);
            btStop.getBackground().setAlpha(255);

            addText("Application Started");

            // update every 1000 milliseconds and only if changed location by at least 10 meters
            locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 1000, 1, locationListener);

            locationManager.requestLocationUpdates(
                LocationManager.NETWORK_PROVIDER, 1000, 1, locationListener);

            phoneStateManager.listen(
                phoneStateListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
          }
        });
    // anonymous class method for Stop button
    btStop.setOnClickListener(
        new OnClickListener() {
          public void onClick(View view) {
            btStart.setEnabled(true);
            btStop.setEnabled(false);
            addText("Application Stopped");
            btStart.getBackground().setAlpha(255);
            btStop.getBackground().setAlpha(127);
            // stop listening for location and signal updates
            locationManager.removeUpdates(locationListener);
            phoneStateManager.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
          }
        });
  } // End of onCreate
Example #26
0
  @Override
  protected Dialog onCreateDialog(int ignore, Bundle args) {

    // TODO set values from "flags" to messagebox dialog

    // get colors

    int[] colors = args.getIntArray("colors");
    int backgroundColor;
    int textColor;
    int buttonBorderColor;
    int buttonBackgroundColor;
    int buttonSelectedColor;
    if (colors != null) {
      int i = -1;
      backgroundColor = colors[++i];
      textColor = colors[++i];
      buttonBorderColor = colors[++i];
      buttonBackgroundColor = colors[++i];
      buttonSelectedColor = colors[++i];
    } else {
      backgroundColor = Color.TRANSPARENT;
      textColor = Color.TRANSPARENT;
      buttonBorderColor = Color.TRANSPARENT;
      buttonBackgroundColor = Color.TRANSPARENT;
      buttonSelectedColor = Color.TRANSPARENT;
    }

    // create dialog with title and a listener to wake up calling thread

    final Dialog dialog = new Dialog(this);
    dialog.setTitle(args.getString("title"));
    dialog.setCancelable(false);
    dialog.setOnDismissListener(
        new DialogInterface.OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface unused) {
            synchronized (messageboxSelection) {
              messageboxSelection.notify();
            }
          }
        });

    // create text

    TextView message = new TextView(this);
    message.setGravity(Gravity.CENTER);
    message.setText(args.getString("message"));
    if (textColor != Color.TRANSPARENT) {
      message.setTextColor(textColor);
    }

    // create buttons

    int[] buttonFlags = args.getIntArray("buttonFlags");
    int[] buttonIds = args.getIntArray("buttonIds");
    String[] buttonTexts = args.getStringArray("buttonTexts");

    final SparseArray<Button> mapping = new SparseArray<Button>();

    LinearLayout buttons = new LinearLayout(this);
    buttons.setOrientation(LinearLayout.HORIZONTAL);
    buttons.setGravity(Gravity.CENTER);
    for (int i = 0; i < buttonTexts.length; ++i) {
      Button button = new Button(this);
      final int id = buttonIds[i];
      button.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              messageboxSelection[0] = id;
              dialog.dismiss();
            }
          });
      if (buttonFlags[i] != 0) {
        // see SDL_messagebox.h
        if ((buttonFlags[i] & 0x00000001) != 0) {
          mapping.put(KeyEvent.KEYCODE_ENTER, button);
        }
        if ((buttonFlags[i] & 0x00000002) != 0) {
          mapping.put(111, button); /* API 11: KeyEvent.KEYCODE_ESCAPE */
        }
      }
      button.setText(buttonTexts[i]);
      if (textColor != Color.TRANSPARENT) {
        button.setTextColor(textColor);
      }
      if (buttonBorderColor != Color.TRANSPARENT) {
        // TODO set color for border of messagebox button
      }
      if (buttonBackgroundColor != Color.TRANSPARENT) {
        Drawable drawable = button.getBackground();
        if (drawable == null) {
          // setting the color this way removes the style
          button.setBackgroundColor(buttonBackgroundColor);
        } else {
          // setting the color this way keeps the style (gradient, padding, etc.)
          drawable.setColorFilter(buttonBackgroundColor, PorterDuff.Mode.MULTIPLY);
        }
      }
      if (buttonSelectedColor != Color.TRANSPARENT) {
        // TODO set color for selected messagebox button
      }
      buttons.addView(button);
    }

    // create content

    LinearLayout content = new LinearLayout(this);
    content.setOrientation(LinearLayout.VERTICAL);
    content.addView(message);
    content.addView(buttons);
    if (backgroundColor != Color.TRANSPARENT) {
      content.setBackgroundColor(backgroundColor);
    }

    // add content to dialog and return

    dialog.setContentView(content);
    dialog.setOnKeyListener(
        new Dialog.OnKeyListener() {
          @Override
          public boolean onKey(DialogInterface d, int keyCode, KeyEvent event) {
            Button button = mapping.get(keyCode);
            if (button != null) {
              if (event.getAction() == KeyEvent.ACTION_UP) {
                button.performClick();
              }
              return true; // also for ignored actions
            }
            return false;
          }
        });

    return dialog;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    Bundle extras = getIntent().getExtras();

    if (extras == null) {
      loadOption = OPTION_DRAW;
      refImage = null;
      savepointImage = new File(Collect.TMPDRAWFILE_PATH);
      savepointImage.delete();
      output = new File(Collect.TMPFILE_PATH);
    } else {
      loadOption = extras.getString(OPTION);
      if (loadOption == null) {
        loadOption = OPTION_DRAW;
      }
      // refImage can also be present if resuming a drawing
      Uri uri = (Uri) extras.get(REF_IMAGE);
      if (uri != null) {
        refImage = new File(uri.getPath());
      }
      String savepoint = extras.getString(SAVEPOINT_IMAGE);
      if (savepoint != null) {
        savepointImage = new File(savepoint);
        if (!savepointImage.exists() && refImage != null && refImage.exists()) {
          FileUtils.copyFile(refImage, savepointImage);
        }
      } else {
        savepointImage = new File(Collect.TMPDRAWFILE_PATH);
        savepointImage.delete();
        if (refImage != null && refImage.exists()) {
          FileUtils.copyFile(refImage, savepointImage);
        }
      }
      uri = (Uri) extras.get(EXTRA_OUTPUT);
      if (uri != null) {
        output = new File(uri.getPath());
      } else {
        output = new File(Collect.TMPFILE_PATH);
      }
    }

    // At this point, we have:
    // loadOption -- type of activity (draw, signature, annotate)
    // refImage -- original image to work with
    // savepointImage -- drawing to use as a starting point (may be copy of
    // original)
    // output -- where the output should be written

    if (OPTION_SIGNATURE.equals(loadOption)) {
      // set landscape
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
      alertTitleString = getString(R.string.quit_application, getString(R.string.sign_button));
    } else if (OPTION_ANNOTATE.equals(loadOption)) {
      alertTitleString = getString(R.string.quit_application, getString(R.string.markup_image));
    } else {
      alertTitleString = getString(R.string.quit_application, getString(R.string.draw_image));
    }

    setTitle(getString(R.string.app_name) + " > " + getString(R.string.draw_image));

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    RelativeLayout v = (RelativeLayout) inflater.inflate(R.layout.draw_layout, null);
    LinearLayout ll = (LinearLayout) v.findViewById(R.id.drawViewLayout);

    drawView = new DrawView(this, OPTION_SIGNATURE.equals(loadOption), savepointImage);

    ll.addView(drawView);

    setContentView(v);

    paint = new Paint();
    paint.setAntiAlias(true);
    paint.setDither(true);
    paint.setColor(currentColor);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeWidth(10);

    pointPaint = new Paint();
    pointPaint.setAntiAlias(true);
    pointPaint.setDither(true);
    pointPaint.setColor(currentColor);
    pointPaint.setStyle(Paint.Style.FILL_AND_STROKE);
    pointPaint.setStrokeWidth(10);

    btnDrawColor = (Button) findViewById(R.id.btnSelectColor);
    btnDrawColor.setTextColor(getInverseColor(currentColor));
    btnDrawColor.getBackground().setColorFilter(currentColor, PorterDuff.Mode.SRC_ATOP);
    btnDrawColor.setText(getString(R.string.set_color));
    btnDrawColor.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Collect.getInstance()
                .getActivityLogger()
                .logInstanceAction(
                    DrawActivity.this,
                    "setColorButton",
                    "click",
                    Collect.getInstance().getFormController().getFormIndex());
            ColorPickerDialog cpd =
                new ColorPickerDialog(
                    DrawActivity.this,
                    new ColorPickerDialog.OnColorChangedListener() {
                      public void colorChanged(String key, int color) {
                        btnDrawColor.setTextColor(getInverseColor(color));
                        btnDrawColor
                            .getBackground()
                            .setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
                        currentColor = color;
                        paint.setColor(color);
                        pointPaint.setColor(color);
                      }
                    },
                    "key",
                    currentColor,
                    currentColor,
                    getString(R.string.select_drawing_color));
            cpd.show();
          }
        });
    btnFinished = (Button) findViewById(R.id.btnFinishDraw);
    btnFinished.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Collect.getInstance()
                .getActivityLogger()
                .logInstanceAction(
                    DrawActivity.this,
                    "saveAndCloseButton",
                    "click",
                    Collect.getInstance().getFormController().getFormIndex());
            SaveAndClose();
          }
        });
    btnReset = (Button) findViewById(R.id.btnResetDraw);
    btnReset.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Collect.getInstance()
                .getActivityLogger()
                .logInstanceAction(
                    DrawActivity.this,
                    "resetButton",
                    "click",
                    Collect.getInstance().getFormController().getFormIndex());
            Reset();
          }
        });
    btnCancel = (Button) findViewById(R.id.btnCancelDraw);
    btnCancel.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            /*				Collect.getInstance()
            .getActivityLogger()
            .logInstanceAction(
            		DrawActivity.this,
            		"cancelAndCloseButton",
            		"click",
            		Collect.getInstance().getFormController()
            				.getFormIndex());*/
            CancelAndClose();
          }
        });
  }
  // 初始化帮助界面控件的监听器
  private void initGameHelpListener() {
    // arrow down动画显示监听
    final AnimationDrawable mArrowDownAnimationDrawable =
        (AnimationDrawable) mHelpArrowDownBtn.getBackground();
    mHelpArrowDownBtn
        .getViewTreeObserver()
        .addOnPreDrawListener(
            new ViewTreeObserver.OnPreDrawListener() {
              boolean mHelpFirst = true;

              public boolean onPreDraw() {
                if (mHelpFirst) {
                  mArrowDownAnimationDrawable.start();
                  mHelpFirst = false;
                }

                return true;
              }
            });

    // arrow up动画显示监听
    final AnimationDrawable mArrowUpAnimationDrawable =
        (AnimationDrawable) mHelpArrowUpBtn.getBackground();
    mHelpArrowUpBtn
        .getViewTreeObserver()
        .addOnPreDrawListener(
            new ViewTreeObserver.OnPreDrawListener() {
              boolean mHelpFirst = true;

              public boolean onPreDraw() {
                if (mHelpFirst) {
                  mArrowUpAnimationDrawable.start();
                  mHelpFirst = false;
                }

                return true;
              }
            });

    // arrow down点击监听
    mHelpArrowDownBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            mGameHelpSv.scrollBy(0, 1000);
            mHelpArrowDownBtn.setVisibility(View.GONE);
            mHelpArrowUpBtn.setVisibility(View.VISIBLE);
          }
        });

    // arrow up点击监听
    mHelpArrowUpBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            mGameHelpSv.scrollBy(0, -1000);
            mHelpArrowDownBtn.setVisibility(View.VISIBLE);
            mHelpArrowUpBtn.setVisibility(View.GONE);
          }
        });

    // help scroller滑动监听
    mGameHelpSv.setOnTouchListener(
        new OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_MOVE) {
              if (mGameHelpSv.getChildAt(0).getMeasuredHeight() - v.getHeight() == v.getScrollY()) {
                mHelpHandler.sendEmptyMessage(MSG_HELP_BUTTON_ARROWDOWN);
              } else if (v.getScrollY() == 0) {
                mHelpHandler.sendEmptyMessage(MSG_HELP_BUTTON_ARROWUP);
              }
            }

            return false;
          }
        });

    mHelpCloseBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mGameHelpListener != null) mGameHelpListener.onGameHelpCloseClick(helpState);
          }
        });
  }
Example #29
0
  /** 界面预设 */
  private void prepare() {
    if (listNews.getHeaderViewsCount() > 0) {
      return;
    }
    animRight =
        new RotateAnimation(
            -30, 30f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animRight.setDuration(1000);
    animRight.setAnimationListener(listener);
    animLeft =
        new RotateAnimation(
            30f, -30f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animLeft.setDuration(1000);
    animLeft.setAnimationListener(listener);
    View viewHead = LayoutInflater.from(this.getActivity()).inflate(R.layout.div_home_head, null);
    listNews.addHeaderView(viewHead);
    scrollEntry = (HorizontalScrollViewEx) viewHead.findViewById(R.id.home_scroll_entry);
    scrollEntry.setHorizontalScrollViewListenner(
        new HorizontalScrollViewEx.HorizontalScrollViewListenner() {
          @Override
          public void onScrollChanged(int x, int y, int oldx, int oldy) {
            if (x > oldx && x > 50) {
              imgDot1.setImageResource(R.drawable.icon_dot_unselected);
              imgDot2.setImageResource(R.drawable.icon_dot_selected);
            } else if (x < oldx && x < 50) {
              imgDot1.setImageResource(R.drawable.icon_dot_selected);
              imgDot2.setImageResource(R.drawable.icon_dot_unselected);
            }
          }
        });
    viewEntry1 = (View) viewHead.findViewById(R.id.home_layout_entry1);
    viewEntry2 = (View) viewHead.findViewById(R.id.home_layout_entry2);
    viewEntry3 = (View) viewHead.findViewById(R.id.home_layout_entry3);
    viewEntry4 = (View) viewHead.findViewById(R.id.home_layout_entry4);
    viewEntry5 = (View) viewHead.findViewById(R.id.home_layout_entry5);
    viewEntry6 = (View) viewHead.findViewById(R.id.home_layout_entry6);
    btnRegion.getBackground().setAlpha(200);
    btnSearch.getBackground().setAlpha(200);
    btnBell.setImageAlpha(200);
    imgDot1 = (ImageView) viewHead.findViewById(R.id.home_image_dot1);
    imgDot2 = (ImageView) viewHead.findViewById(R.id.home_image_dot2);
    browser = (ScrollWebView) viewHead.findViewById(R.id.home_browser);

    DisplayMetrics metrics = new DisplayMetrics();
    this.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    LayoutParams lp = (LayoutParams) browser.getLayoutParams();
    lp.height = metrics.widthPixels * 7 / 10;
    browser.setLayoutParams(lp);

    browser.getSettings().setJavaScriptEnabled(true);
    browser.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    browser.setWebViewClient(
        new WebViewClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView view, String url) {
            Intent intent = new Intent(HomeActivity.this.getActivity(), BrowserActivity.class);
            intent.putExtra("url", url);
            startActivity(intent);
            browser.pauseTimers();
            browser.resumeTimers();
            return true;
          }

          @Override
          public void onReceivedError(
              WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);
            browser.loadUrl("about:blank");
          }
        });

    View viewActivity1 = (View) viewHead.findViewById(R.id.home_layout_left);
    viewActivity1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String token = "";
            if (null != Me.instance) {
              token = Me.instance.token;
            }
            String regionId = "";
            if (null != Profile.instance().region) {
              regionId = String.valueOf(Profile.instance().region.id);
            }
            Helper.openBrowser(
                HomeActivity.this.getActivity(), Networking.fetchURL("activity1", token, regionId));
          }
        });
    View viewActivity2 = (View) viewHead.findViewById(R.id.home_layout_right);
    viewActivity2.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            String token = "";
            if (null != Me.instance) {
              token = Me.instance.token;
            }
            String regionId = "";
            if (null != Profile.instance().region) {
              regionId = String.valueOf(Profile.instance().region.id);
            }
            Helper.openBrowser(
                HomeActivity.this.getActivity(), Networking.fetchURL("activity2", token, regionId));
          }
        });
    this.getActivity().findViewById(R.id.home_layout_header).bringToFront();
  }
  @Override
  public void onClick(final View v) {
    if (v == btnCalendarStart) {
      // Launch Date Picker Dialog
      DatePickerDialog dpdStart =
          new DatePickerDialog(
              this,
              new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  // Display Selected date in textbox
                  txtDateStart.setText(
                      String.format("%02d", dayOfMonth)
                          + "/"
                          + String.format("%02d", (monthOfYear + 1))
                          + "/"
                          + year);
                  startYear = year;
                  startMonth = monthOfYear;
                  startDay = dayOfMonth;
                }
              },
              startYear,
              startMonth,
              startDay);
      dpdStart.show();
    }
    if (v == btnCalendarEnd) {
      // Launch End Date Picker Dialog
      DatePickerDialog dpdEnd =
          new DatePickerDialog(
              this,
              new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  txtDateEnd.setText(
                      String.format("%02d", dayOfMonth)
                          + "/"
                          + String.format("%02d", (monthOfYear + 1))
                          + "/"
                          + year);
                  endYear = year;
                  endMonth = monthOfYear;
                  endDay = dayOfMonth;
                }
              },
              endYear,
              endMonth,
              endDay);
      dpdEnd.show();
    }
    if (v == btnTimeStart) {
      // Launch Time Picker Dialog
      TimePickerDialog tpdStart =
          new TimePickerDialog(
              this,
              new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                  startHour = hourOfDay;
                  startMinute = minute;

                  if (startMinute != 0) {
                    Date startDate =
                        convertStringToDate(
                            startDay, startMonth, startYear, startHour, startMinute);
                    Date startDateRoundedToNearestHour = roundToNearestHour(startDate);

                    SimpleDateFormat sdf =
                        new SimpleDateFormat("dd/MM/yyyy HH:mm"); // the format of your date
                    sdf.setTimeZone(
                        TimeZone.getTimeZone("GMT-5")); // give a timezone reference for formating
                    String formattedDate = sdf.format(startDateRoundedToNearestHour);

                    String[] formattedDateSeparated = formattedDate.split(" ");
                    String[] formatDate = formattedDateSeparated[0].split("/");
                    String[] formatTime = formattedDateSeparated[1].split(":");

                    startDay = Integer.parseInt(formatDate[0]);
                    startMonth = Integer.parseInt(formatDate[1]) - 1;
                    startYear = Integer.parseInt(formatDate[2]);
                    startHour = Integer.parseInt(formatTime[0]);
                    startMinute = Integer.parseInt(formatTime[1]);

                    txtDateStart.setText(
                        String.format("%02d", startDay)
                            + "/"
                            + String.format("%02d", (startMonth + 1))
                            + "/"
                            + startYear);
                  }

                  txtTimeStart.setText(
                      String.format("%02d", startHour) + ":" + String.format("%02d", startMinute));
                }
              },
              startHour,
              startMinute,
              false);
      tpdStart.show();
    }

    if (v == btnTimeEnd) {
      // Launch Time Picker Dialog
      TimePickerDialog tpdEnd =
          new TimePickerDialog(
              this,
              new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                  endHour = hourOfDay;
                  endMinute = minute;
                  if (endMinute != 0) {
                    Date endDate =
                        convertStringToDate(endDay, endMonth, endYear, endHour, endMinute);
                    Date endDateRoundedToNearestHour = roundToNearestHour(endDate);

                    SimpleDateFormat sdf =
                        new SimpleDateFormat("dd/MM/yyyy HH:mm"); // the format of your date
                    sdf.setTimeZone(
                        TimeZone.getTimeZone("GMT-5")); // give a timezone reference for formating
                    String formattedDate = sdf.format(endDateRoundedToNearestHour);

                    String[] formattedDateSeparated = formattedDate.split(" ");
                    String[] formatDate = formattedDateSeparated[0].split("/");
                    String[] formatTime = formattedDateSeparated[1].split(":");

                    endDay = Integer.parseInt(formatDate[0]);
                    endMonth = Integer.parseInt(formatDate[1]) - 1;
                    endYear = Integer.parseInt(formatDate[2]);
                    endHour = Integer.parseInt(formatTime[0]);
                    endMinute = Integer.parseInt(formatTime[1]);

                    txtDateEnd.setText(
                        String.format("%02d", endDay)
                            + "/"
                            + String.format("%02d", (endMonth + 1))
                            + "/"
                            + endYear);
                  }

                  txtTimeEnd.setText(
                      String.format("%02d", endHour) + ":" + String.format("%02d", endMinute));
                }
              },
              endHour,
              endMinute,
              false);
      tpdEnd.show();
    }

    if (v == submitUpdate) {
      if (userSelectedDestination == null) {
        if (apiResults.getListings() != null) {
          mMap = mapFragment.getMap();
          mMap.clear();
        }
        Toast.makeText(MainActivity.this, "Destination cannot be empty", Toast.LENGTH_SHORT).show();
      } else {
        if (doDateTimeValidation()) {
          spinner.setVisibility(View.VISIBLE);
          submitUpdate.setEnabled(false);
          autoCompView.setFocusable(false);
          autoCompView.setFocusableInTouchMode(true);
          submitUpdate.getBackground().setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY);
          String sorting = "rating";
          int checked_restroom = 0;
          int checked_mobile = 0;
          int checked_indoor = 0;
          int checked_attended = 0;
          int checked_security = 0;
          int checked_valet = 0;
          long epoch_start = userSelectedStartDateTime;
          long epoch_end = userSelectedEndDateTime;
          String urlString =
              "http://api.parkwhiz.com/search?destination="
                  + userSelectedDestination
                  + "&key="
                  + getResources().getString(R.string.park_whiz_key)
                  + "&start="
                  + epoch_start
                  + "&end="
                  + epoch_end
                  + "&sort="
                  + sorting
                  + "&restroom="
                  + 0
                  + "&security="
                  + 0
                  + "&valet="
                  + 0
                  + "&indoor="
                  + 0
                  + "&eticket="
                  + 0
                  + "&attended="
                  + 0;

          Toast.makeText(MainActivity.this, "Sending your request", Toast.LENGTH_SHORT).show();
          mMap = mapFragment.getMap();
          mMap.clear();
          apiResults = new GetAPIResults(getBaseContext(), mapFragment, this);
          apiResults.execute(urlString);
          hideSoftKeyboard();
        }
      }
    }
  }