Пример #1
1
 public boolean onDrag(View v, DragEvent event) {
   final int action = event.getAction();
   switch (action) {
     case DragEvent.ACTION_DRAG_STARTED:
       if (event.getClipDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
         ((ImageView) v).setColorFilter(Color.BLUE);
         Toast.makeText(DragAndDropActivity.this, "ACTION_DRAG_STARTED", Toast.LENGTH_SHORT)
             .show();
         v.invalidate();
         return true;
       } else {
         return false;
       }
     case DragEvent.ACTION_DRAG_ENTERED:
       ((ImageView) v).setColorFilter(Color.GREEN);
       Toast.makeText(DragAndDropActivity.this, "ACTION_DRAG_ENTERED", Toast.LENGTH_SHORT)
           .show();
       v.invalidate();
       return true;
     case DragEvent.ACTION_DRAG_LOCATION:
       return true;
     case DragEvent.ACTION_DRAG_EXITED:
       ((ImageView) v).setColorFilter(Color.RED);
       Toast.makeText(DragAndDropActivity.this, "ACTION_DRAG_EXITED", Toast.LENGTH_SHORT).show();
       v.invalidate();
       return true;
     case DragEvent.ACTION_DROP:
       ClipData.Item item = event.getClipData().getItemAt(0);
       CharSequence dragData = item.getText();
       Toast.makeText(
               DragAndDropActivity.this, "Dragged data is " + dragData, Toast.LENGTH_SHORT)
           .show();
       ((ImageView) v).clearColorFilter();
       v.invalidate();
       return true;
     case DragEvent.ACTION_DRAG_ENDED:
       ((ImageView) v).clearColorFilter();
       v.invalidate();
       if (event.getResult()) {
         Toast.makeText(DragAndDropActivity.this, "The drop was handled.", Toast.LENGTH_SHORT)
             .show();
       } else {
         Toast.makeText(DragAndDropActivity.this, "The drop didn't work.", Toast.LENGTH_SHORT)
             .show();
       }
       ;
       return true;
     default:
       Log.e("DragDrop Example", "Unknown action type received by OnDragListener.");
       break;
   }
   ;
   return false;
 };
Пример #2
0
  @Override
  public void onClick(View v) {
    findImage.clearColorFilter();
    libImage.clearColorFilter();
    contriImage.clearColorFilter();
    switch (v.getId()) {
      case R.id.activity_main_find:
        findImage.setColorFilter(getResources().getColor(R.color.tab_selectecolor));
        mPagers.setCurrentItem(0);
        break;
      case R.id.activity_main_contri:
        contriImage.setColorFilter(getResources().getColor(R.color.tab_selectecolor));
        if (!(PreferenceManager.getDefaultSharedPreferences(this)
            .getBoolean("login_state", false))) {
          Intent intent = new Intent(MainActivity.this, LoginActivity.class);
          startActivity(intent);
        } else {
          mPagers.setCurrentItem(1);
        }

        break;
      case R.id.activity_main_lib:
        libImage.setColorFilter(getResources().getColor(R.color.tab_selectecolor));
        mPagers.setCurrentItem(2);
        break;
    }
  }
Пример #3
0
 public void fillView(Resolver resolver) {
   TextView textView1 = (TextView) findViewById(R.id.textview1);
   textView1.setText(resolver.getPrettyName());
   ImageView imageView1 = (ImageView) findViewById(R.id.imageview1);
   imageView1.clearColorFilter();
   if (!(resolver instanceof ScriptResolver)
       || ((ScriptResolver) resolver).getScriptAccount().getMetaData().manifest.iconBackground
           != null) {
     resolver.loadIconBackground(imageView1, !resolver.isEnabled());
   } else {
     if (resolver.isEnabled()) {
       imageView1.setBackgroundColor(
           TomahawkApp.getContext().getResources().getColor(android.R.color.black));
     } else {
       imageView1.setBackgroundColor(
           TomahawkApp.getContext().getResources().getColor(R.color.fallback_resolver_bg));
     }
   }
   ImageView imageView2 = (ImageView) findViewById(R.id.imageview2);
   if (!(resolver instanceof ScriptResolver)
       || ((ScriptResolver) resolver).getScriptAccount().getMetaData().manifest.iconWhite
           != null) {
     resolver.loadIconWhite(imageView2);
   } else {
     resolver.loadIcon(imageView2, !resolver.isEnabled());
   }
   View connectImageViewContainer = findViewById(R.id.connect_imageview);
   if (resolver.isEnabled()) {
     connectImageViewContainer.setVisibility(View.VISIBLE);
   } else {
     connectImageViewContainer.setVisibility(View.GONE);
   }
 }
Пример #4
0
 @Override
 public boolean onResourceReady(
     GlideDrawable resource,
     String model,
     Target<GlideDrawable> target,
     boolean isFromMemoryCache,
     boolean isFirstResource) {
   GlideAnimation<GlideDrawable> animation =
       new DrawableCrossFadeFactory<GlideDrawable>().build(isFromMemoryCache, isFirstResource);
   mImageView.clearColorFilter();
   mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
   target.onResourceReady(resource, animation);
   return true;
 }
Пример #5
0
 protected void dimImmovableTiles(boolean on) {
   final Board board = getBoardModel();
   final int boardSize = board.getSize();
   final int color = getResources().getColor(R.color.tile_dimmer);
   for (int r = 0; r < boardSize; r++)
     for (int c = 0; c < boardSize; c++) {
       final ImageView cell = imageCells[r][c];
       final Object tag = cell.getTag();
       if (tag instanceof Tile
           && null == board.permittedMoveFor((Tile) tag)
           && 0 != ((Tile) tag).getNumber()) {
         if (on) cell.setColorFilter(color);
         else cell.clearColorFilter();
       }
     }
 }
Пример #6
0
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        notes = "Test {@link ImageView#clearColorFilter()}",
        method = "clearColorFilter",
        args = {}
    )
    public void testClearColorFilter() {
        MockDrawable drawable = new MockDrawable();
        ColorFilter cf = new ColorFilter();

        ImageView imageView = new ImageView(mActivity);
        imageView.setImageDrawable(drawable);
        imageView.setColorFilter(cf);

        imageView.clearColorFilter();
        assertNull(drawable.getColorFilter());
    }
Пример #7
0
 @SuppressLint("ClickableViewAccessibility")
 @Override
 public boolean onTouch(View v, MotionEvent event) {
   switch (event.getAction()) {
     case MotionEvent.ACTION_DOWN:
       {
         ((ImageView) v).getDrawable().setColorFilter(0xe0f47521, Mode.SRC_ATOP);
         ((ImageView) v).invalidate();
         break;
       }
     case MotionEvent.ACTION_UP:
       {
         ((ImageView) v).getDrawable().clearColorFilter();
         ((ImageView) v).invalidate();
         break;
       }
   }
   return false;
 }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    if (values.get(position).isSection()) {
      ImageView view = new ImageView(context);
      if (m.theme1 == 0) view.setImageResource(R.color.divider);
      else view.setImageResource(R.color.divider_dark);
      view.setClickable(false);
      view.setFocusable(false);
      if (m.theme1 == 0) view.setBackgroundColor(Color.WHITE);
      else view.setBackgroundResource(R.color.background_material_dark);
      view.setLayoutParams(
          new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17)));
      view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8));
      return view;
    } else {
      View view = inflater.inflate(R.layout.drawerrow, parent, false);
      final TextView txtTitle = (TextView) view.findViewById(R.id.firstline);
      final ImageView imageView = (ImageView) view.findViewById(R.id.icon);
      if (m.theme1 == 0) {
        view.setBackgroundResource(R.drawable.safr_ripple_white);
      } else {
        view.setBackgroundResource(R.drawable.safr_ripple_black);
      }
      view.setOnClickListener(
          new View.OnClickListener() {

            public void onClick(View p1) {
              m.selectItem(position);
            }
            // TODO: Implement this method

          });
      view.setOnLongClickListener(
          new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              if (!getItem(position).isSection())
                // not to remove the first bookmark (storage) and permanent bookmarks
                if (position > m.storage_count && position < values.size() - 7) {
                  EntryItem item = (EntryItem) getItem(position);
                  String path = (item).getPath();
                  if (m.mainActivityHelper.contains(path, m.books) != -1) {
                    m.renameBookmark(((EntryItem) getItem(position)).getTitle(), path);
                  } else if (path.startsWith("smb:/")) {
                    m.showSMBDialog(item.getTitle(), path, true);
                  }
                } else if (position < m.storage_count) {
                  String path = ((EntryItem) getItem(position)).getPath();
                  if (!path.equals("/"))
                    new Futils()
                        .showProps(RootHelper.generateBaseFile(new File(path), true), m, m.theme1);
                }

              // return true to denote no further processing
              return true;
            }
          });

      txtTitle.setText(((EntryItem) (values.get(position))).getTitle());
      imageView.setImageDrawable(getDrawable(position));
      imageView.clearColorFilter();
      if (myChecked.get(position)) {
        if (m.theme1 == 0) view.setBackgroundColor(Color.parseColor("#ffeeeeee"));
        else view.setBackgroundColor(Color.parseColor("#ff424242"));
        imageView.setColorFilter(fabskin);
        txtTitle.setTextColor(Color.parseColor(m.fabskin));
      } else {
        if (m.theme1 == 0) {
          imageView.setColorFilter(Color.parseColor("#666666"));
          txtTitle.setTextColor(m.getResources().getColor(android.R.color.black));
        } else {
          imageView.setColorFilter(Color.WHITE);
          txtTitle.setTextColor(m.getResources().getColor(android.R.color.white));
        }
      }

      return view;
    }
  }
Пример #9
0
  // It executes when the sensor change
  @Override
  public void onSensorChanged(SensorEvent event) {
    // Can change the accelerometer or the magnetometer
    if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) mGravity = event.values.clone();
    if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) mGeomagnetic = event.values.clone();

    // Need the data of both sensors for the compass
    if ((mGravity != null) && (mGeomagnetic != null)) {
      /*
       * For the orientation of the device, it calculates the azimut:
       * "angle of the reference (north) and a line in the middle of the observer
       * and the interest point in the same direction field" - Wikipedia
       * If the azimut is 0º, the device is oriented to the North, 90º to the East,
       * 180º to the South and 270º to the West
       *
       * For calculate the azimut, first calculate the rotation matrix (using the
       * accelerometer and magnetometer data) and after it uses this matrix obtaining
       * a vector that his first coordinate is de azimut
       */
      SensorManager.getRotationMatrix(rotationMatrix, null, mGravity, mGeomagnetic);
      SensorManager.getOrientation(rotationMatrix, orientation);

      float azimut = orientation[0]; // orientation contains: azimut, pitch and roll

      // Azimut to degrees
      float deviceOrientation = (float) (Math.toDegrees(azimut) + 360) % 360;

      boolean rightHeading = isInTheRightDirection(deviceOrientation);

      // changes the arrow color when the user is taking the good direction
      if (rightHeading) {
        int green = Color.parseColor("#008000"); // Green colour
        image.setColorFilter(green);
      } else {
        image.clearColorFilter();
      }

      // animate the image change for an smooth visualization
      RotateAnimation animation =
          new RotateAnimation(
              previusOrientation,
              -(deviceOrientation - providedOrientation),
              Animation.RELATIVE_TO_SELF,
              0.5f,
              Animation.RELATIVE_TO_SELF,
              0.5f);

      // how long the animation will take place
      animation.setDuration(210);

      // set the animation after the end of the reservation status
      animation.setFillAfter(true);

      tvHeading.setText(
          getString(R.string.compass_heading)
              + Float.toString((deviceOrientation - providedOrientation + 360) % 360)
              + getString(R.string.compass_degrees));

      // start the animation
      image.startAnimation(animation);

      // save the orientation for the next animation
      previusOrientation = -(deviceOrientation - providedOrientation);
    }
  }
Пример #10
0
 private void enableImage(ImageView imageView) {
     imageView.clearColorFilter();
 }