コード例 #1
1
 public void onRadioButtonClicked(View v) {
   if (v.getId() == R.id.group_closed_radio) {
     groupLogo.setImageResource(R.drawable.group_closed);
     groupLogo.setBackgroundColor(R.color.color_primary);
     groupTypeDescr.setText(R.string.group_closed_description);
     Log.e(
         TAG,
         "Cliccato: "
             + v.getId()
             + "! Setto: "
             + R.drawable.group_closed
             + ", "
             + R.color.color_primary
             + ", "
             + R.string.group_closed_description);
   } else if (v.getId() == R.id.group_open_radio) {
     groupLogo.setImageResource(R.drawable.group_open);
     groupLogo.setBackgroundColor(R.color.color_primary);
     groupTypeDescr.setText(R.string.group_open_description);
     Log.e(
         TAG,
         "Cliccato: "
             + v.getId()
             + "! Setto: "
             + R.drawable.group_open
             + ", "
             + R.color.color_primary
             + ", "
             + R.string.group_open_description);
   }
 }
コード例 #2
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);
   }
 }
コード例 #3
0
  private static void process4140Response(final String data) {

    final String[] buf = data.substring(data.indexOf(SEVEN_REGISTERS), data.length()).split(" ");

    if (ModbusRTU.validCRC(buf, REGISTER_4140_LENGTH)) {
      imgStatus.setBackgroundColor(Color.GREEN);

      setLearningFlags(new String[] {"0", "0", "0", buf[15], buf[16]});
      targetAFR = Integer.parseInt(buf[3] + buf[4], 16) / 10f;
      closedLoop = (getBit(Integer.parseInt(buf[9] + buf[10], 16), 8) > 0);

      if (closedLoop) {
        txtFuelLearn.setBackgroundColor(Color.GREEN);
      } else {
        txtFuelLearn.setBackgroundColor(Color.TRANSPARENT);
      }

      txtData.setText(
          String.format("AVG: %d ms - TPS: %d%%", (int) totalTimeMillis / updatesReceived, tps));

      if (DEBUG_MODE) Log.d(TAG, "Processed " + lastRegister + " response: " + data);
      sendRequest(REGISTER_4096_PLUS_SEVEN);
      return;

    } else {
      if (DEBUG_MODE) Log.d(TAG, "bad CRC for " + lastRegister + ": " + data);
      imgStatus.setBackgroundColor(Color.RED);
      sendRequest();
    }
  }
コード例 #4
0
 public void loadBitmap(Message message, ImageView imageView) {
   Bitmap bm;
   try {
     bm =
         xmppConnectionService
             .getFileBackend()
             .getThumbnail(message, (int) (metrics.density * 288), true);
   } catch (FileNotFoundException e) {
     bm = null;
   }
   if (bm != null) {
     imageView.setImageBitmap(bm);
     imageView.setBackgroundColor(0x00000000);
   } else {
     if (cancelPotentialWork(message, imageView)) {
       imageView.setBackgroundColor(0xff333333);
       final BitmapWorkerTask task = new BitmapWorkerTask(imageView);
       final AsyncDrawable asyncDrawable = new AsyncDrawable(getResources(), null, task);
       imageView.setImageDrawable(asyncDrawable);
       try {
         task.execute(message);
       } catch (final RejectedExecutionException ignored) {
       }
     }
   }
 }
コード例 #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_new_game);
    Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/PoiretOne-Regular.ttf");
    TextView titleTextView = (TextView) findViewById(R.id.new_game_title);
    titleTextView.setTypeface(typeface);

    final ImageView leftImage = (ImageView) findViewById(R.id.select_left_image_view);
    final ImageView rightImage = (ImageView) findViewById(R.id.select_right_image_view);
    leftImage.setPadding(1, 1, 1, 1);
    rightImage.setPadding(1, 1, 1, 1);

    leftSelected = true;
    leftImage.setBackgroundColor(getResources().getColor(R.color.red));
    rightImage.setBackgroundColor(getResources().getColor(R.color.transparent));

    leftImage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            leftSelected = true;
            leftImage.setBackgroundColor(getResources().getColor(R.color.red));
            rightImage.setBackgroundColor(getResources().getColor(R.color.transparent));
          }
        });
    rightImage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            leftSelected = false;
            leftImage.setBackgroundColor(getResources().getColor(R.color.transparent));
            rightImage.setBackgroundColor(getResources().getColor(R.color.blue));
          }
        });

    Button startButton = (Button) findViewById(R.id.finishButton);
    startButton.setTypeface(typeface);

    startButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            SharedPreferences sharedPref =
                getSharedPreferences(Constants.SHARED_PREFERENCE, MODE_PRIVATE);
            SharedPreferences.Editor editor = sharedPref.edit();

            editor.putString(getString(R.string.self_instance_id), leftSelected ? "Tom" : "Jerry");
            editor.putString(getString(R.string.self_base_instance_id), leftSelected ? "X" : "Y");
            editor.putString(
                getString(R.string.opponent_instance_id), leftSelected ? "Jerry" : "Tom");
            editor.putString(
                getString(R.string.opponent_base_instance_id), leftSelected ? "Y" : "X");
            editor.commit();

            setResult(RESULT_OK);
            finish();
          }
        });
  }
コード例 #6
0
  public void startAnimation() {
    if (item == null) {
      return;
    }

    foregroundImage = new ImageView(context);
    if (item.getForeground().getColor() != null) {
      foregroundImage.setBackgroundColor(Color.parseColor(item.getForeground().getColor()));
    }

    if (item.getForeground().getImage() != null) {
      try {
        FileInputStream fileInputStream =
            new FileInputStream(
                Environment.getExternalStorageDirectory() + File.separator + "1.png");
        Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream);
        foregroundImage.setImageBitmap(bitmap);
      } catch (IOException e) {
        Log.e(TAG, e.getMessage(), e);
      }
    }

    AbsoluteLayout.LayoutParams foregroundParams =
        new AbsoluteLayout.LayoutParams(
            item.getGeometry().getWidth(), item.getGeometry().getHeight(),
            item.getGeometry().getLeft(), item.getGeometry().getTop());
    foregroundImage.setLayoutParams(foregroundParams);
    layout.addView(foregroundImage);

    backgroundImage = new ImageView(context);
    if (item.getBackground().getColor() != null) {
      backgroundImage.setBackgroundColor(Color.parseColor(item.getBackground().getColor()));
    }

    if (item.getBackground().getImage() != null) {
      try {
        FileInputStream fileInputStream =
            new FileInputStream(
                Environment.getExternalStorageDirectory() + File.separator + "1.png");
        Bitmap bitmap = BitmapFactory.decodeStream(fileInputStream);
        backgroundImage.setImageBitmap(bitmap);
      } catch (IOException e) {
        Log.e(TAG, e.getMessage(), e);
      }
    }

    AbsoluteLayout.LayoutParams backgroundParams =
        new AbsoluteLayout.LayoutParams(
            item.getGeometry().getWidth(), item.getGeometry().getHeight(),
            item.getGeometry().getLeft(), item.getGeometry().getTop());
    backgroundImage.setLayoutParams(backgroundParams);

    AlphaAnimation animation = new AlphaAnimation(0f, 1.0f);
    animation.setDuration(item.getDuration() * 1000);
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    backgroundImage.startAnimation(animation);
    layout.addView(backgroundImage);
  }
コード例 #7
0
ファイル: Loader3.java プロジェクト: 13leaf/QADDroid
 @Override
 public void display(ImageView img, Bitmap bmp) {
   if (bmp == null) {
     img.setBackgroundColor(Color.RED);
   } else {
     img.setBackgroundColor(Color.BLACK);
     img.setImageBitmap(bmp);
   }
 }
コード例 #8
0
ファイル: MyBBsNote.java プロジェクト: sk19871216/Yilife
 public void setposition3() {
   tv_list1.setTextColor(android.graphics.Color.parseColor("#000000"));
   iv1.setBackgroundColor(android.graphics.Color.parseColor("#00ffffff"));
   tv_list2.setTextColor(android.graphics.Color.parseColor("#000000"));
   iv2.setBackgroundColor(android.graphics.Color.parseColor("#00ffffff"));
   tv_list3.setTextColor(android.graphics.Color.parseColor("#209df3"));
   iv3.setBackgroundColor(android.graphics.Color.parseColor("#209df3"));
   vp.setCurrentItem(2);
 }
コード例 #9
0
 @Override
 public View getView(int i, View view, ViewGroup viewGroup) {
   int type = getItemViewType(i);
   if (type == 0) {
     if (view == null) {
       LayoutInflater li =
           (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       view = li.inflate(R.layout.settings_wallpapers_my_row, viewGroup, false);
     }
     View parentView = view.findViewById(R.id.parent);
     ImageView imageView = (ImageView) view.findViewById(R.id.image);
     View selection = view.findViewById(R.id.selection);
     if (i == 0) {
       if (selectedBackground == -1 || selectedColor != 0 || selectedBackground == 1000001) {
         imageView.setBackgroundColor(0x5A475866);
       } else {
         imageView.setBackgroundColor(0x5A000000);
       }
       imageView.setImageResource(R.drawable.ic_gallery_background);
       if (selectedBackground == -1) {
         selection.setVisibility(View.VISIBLE);
       } else {
         selection.setVisibility(View.INVISIBLE);
       }
     } else {
       imageView.setImageBitmap(null);
       TLRPC.WallPaper wallPaper = wallPapers.get(i - 1);
       imageView.setBackgroundColor(0xff000000 | wallPaper.bg_color);
       if (wallPaper.id == selectedBackground) {
         selection.setVisibility(View.VISIBLE);
       } else {
         selection.setVisibility(View.INVISIBLE);
       }
     }
   } else if (type == 1) {
     if (view == null) {
       LayoutInflater li =
           (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       view = li.inflate(R.layout.settings_wallpapers_other_row, viewGroup, false);
     }
     BackupImageView image = (BackupImageView) view.findViewById(R.id.image);
     View selection = view.findViewById(R.id.selection);
     TLRPC.WallPaper wallPaper = wallPapers.get(i - 1);
     TLRPC.PhotoSize size =
         FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, AndroidUtilities.dp(100));
     if (size != null && size.location != null) {
       image.setImage(size.location, "100_100", 0);
     }
     if (wallPaper.id == selectedBackground) {
       selection.setVisibility(View.VISIBLE);
     } else {
       selection.setVisibility(View.INVISIBLE);
     }
   }
   return view;
 }
コード例 #10
0
  @Override
  protected View onCreateDialogView() {
    LinearLayout.LayoutParams params;
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);

    mColorView = new ImageView(mContext);
    mColorView.setMinimumHeight(30);
    mColorView.setBackgroundColor(0xffff0000);
    params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params.bottomMargin = 25;
    layout.addView(mColorView, params);

    mSeekBarR = new SeekBar(mContext);
    mSeekBarR.setOnSeekBarChangeListener(this);
    mSeekBarR.getProgressDrawable().setColorFilter(0xbbff0000, PorterDuff.Mode.SRC_OVER);
    layout.addView(
        mSeekBarR,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    mSeekBarG = new SeekBar(mContext);
    mSeekBarG.setOnSeekBarChangeListener(this);
    mSeekBarG.getProgressDrawable().setColorFilter(0xbb00ff00, PorterDuff.Mode.SRC_OVER);
    layout.addView(
        mSeekBarG,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    mSeekBarB = new SeekBar(mContext);
    mSeekBarB.setOnSeekBarChangeListener(this);
    mSeekBarB.getProgressDrawable().setColorFilter(0xbb0000ff, PorterDuff.Mode.SRC_OVER);
    layout.addView(
        mSeekBarB,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    if (shouldPersist()) {
      mValue = getPersistedInt(mDefault);
      mRed = (mValue & 0x00ff0000) >> 16;
      mGreen = (mValue & 0x0000ff00) >> 8;
      mBlue = mValue & 0x000000ff;
    }

    mSeekBarR.setMax(mMax);
    mSeekBarR.setProgress(mRed);
    mSeekBarG.setMax(mMax);
    mSeekBarG.setProgress(mGreen);
    mSeekBarB.setMax(mMax);
    mSeekBarB.setProgress(mBlue);
    mColorView.setBackgroundColor(mValue | 0xff000000);
    return (layout);
  }
コード例 #11
0
 private void toggleActivityImage(boolean onOff) {
   if (onOff) {
     imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher));
   } else {
     SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
     String newColor = sharedPref.getString(SettingsActivity.PREF_COLOR, "white");
     if (newColor.equalsIgnoreCase("black")) {
       imageView.setBackgroundColor(getResources().getColor(android.R.color.black));
     } else {
       imageView.setBackgroundColor(getResources().getColor(android.R.color.white));
     }
   }
 }
コード例 #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view);

    Intent intent = getIntent();
    String Name = intent.getStringExtra("viewname");
    String phoneNum = intent.getStringExtra("viewphone");
    sex = intent.getStringExtra("viewsex");
    int resId = 0;
    try {
      resId = Integer.parseInt(intent.getStringExtra("resID"));
    } catch (Exception e) {

    }
    TextView txtName = (TextView) findViewById(R.id.view_name);
    txtName.setText(Name);

    ImageView titleView = (ImageView) findViewById(R.id.imgTitle);
    if (sex.equals("1")) {
      titleView.setBackgroundColor(getResources().getColor(R.color.title_pink));
    } else {
      titleView.setBackgroundColor(getResources().getColor(R.color.title_green));
    }

    QRlevel = (RelativeLayout) findViewById(R.id.QRlevel);

    txtPhoneNum = (TextView) findViewById(R.id.view_phoneNum);
    txtPhoneNum.setText(phoneNum);
    RQcode =
        "LSTXL-VCARD;"
            + txtName.getText().toString()
            + ";"
            + txtPhoneNum.getText().toString()
            + ";"
            + sex
            + "";
    imgOutput = (ImageView) findViewById(R.id.img_main_output);
    imgProple = (ImageView) findViewById(R.id.imgPeopleIcon);
    // Toast.makeText(this,resId+"",Toast.LENGTH_SHORT).show();
    imgProple.setImageResource(resId);
    createImage();

    Integer[] mButtonState = {
      R.drawable.view_call_button, R.drawable.btn_view_call, R.drawable.btn_view_call_down
    };
    Button mButton = (Button) findViewById(R.id.btn_callPhone);
    MyButton myButton = new MyButton(this);
    mButton.setBackgroundDrawable(myButton.setbg(mButtonState));
  }
コード例 #13
0
ファイル: LCD.java プロジェクト: chehongbin/FactoryTest
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    if (isDouldClick()) {
      return;
    }
    switch (v.getId()) {
      case R.id.img_lcd:
        if (mImageNum == 8) {
          mivPicture.setBackgroundResource(R.drawable.lcd_test_01);
          mImageNum--;
        } else if (mImageNum == 7) {
          mivPicture.setBackgroundResource(R.drawable.lcd_test_02);
          mImageNum--;
        } else if (mImageNum == 6) {
          mivPicture.setBackgroundResource(R.drawable.lcd_test_03);
          mImageNum--;
        } else if (mImageNum == 5) {
          mivPicture.setBackgroundColor(Color.RED);
          mImageNum--;
        } else if (mImageNum == 4) {
          mivPicture.setBackgroundColor(Color.GREEN);
          mImageNum--;
        } else if (mImageNum == 3) {
          mivPicture.setBackgroundColor(Color.BLUE);
          mImageNum--;
        } else if (mImageNum == 2) {
          mivPicture.setBackgroundColor(Color.WHITE);
          mImageNum--;
        } else if (mImageNum == 1) {
          mivPicture.setBackgroundColor(Color.BLACK);
          mImageNum--;
        } else if (mImageNum == 0) {
          // mView.setBackgroundColor(color.floralwhite);
          mivPicture.setVisibility(View.INVISIBLE);
          mView.setBackgroundColor(0xFFFAF0);
          ItemTestActivity.itemActivity.handler.sendEmptyMessage(
              ItemTestActivity.MSG_BTNBAR_VISIBLE);
          mtvPrompt.setVisibility(View.VISIBLE);
          mtvLcdTitle.setVisibility(View.VISIBLE);
        }

        break;

      default:
        break;
    }
  }
コード例 #14
0
ファイル: VpHeaderAdapter.java プロジェクト: devzld/YunKeTang
  @Override
  public Object instantiateItem(ViewGroup container, int position) {

    //        Log.i(TAG, "instantiateItem: "+container.getLayoutParams().width);
    //        ImageView image = (ImageView) container.getChildAt(position);

    //        image.setLayoutParams(params);
    String url = mImageIds[position];
    ImageView imageView = new ImageView(mContext);
    imageView.setBackgroundColor(Color.RED);

    Log.i(TAG, "instantiateItem Width: " + imageView.getMeasuredWidth());
    Log.i(TAG, "instantiateItem Height " + imageView.getMeasuredHeight());
    /*ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(1200,600);
    imageView.setLayoutParams(params);*/
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);
    imageView.setImageResource(R.mipmap.ic_launcher);
    /*        ViewGroup.LayoutParams lp= imageView.getLayoutParams();
    lp.width = 1200;
    lp.height = 600;
    imageView.setLayoutParams(lp);*/
    // Log.i(TAG, "instantiateItem: 123" + imageView.getLayoutParams().width);

    imageView.setTag(url);
    ImageLoader.getInstance().showBitmap(url, imageView);
    list.add(imageView);
    container.addView(imageView);
    return imageView;
  }
コード例 #15
0
ファイル: TouchListView.java プロジェクト: yelmu/callmeter
  private void startDragging(final Bitmap bm, final int y) {
    this.stopDragging();

    this.mWindowParams = new WindowManager.LayoutParams();
    this.mWindowParams.gravity = Gravity.TOP;
    this.mWindowParams.x = 0;
    this.mWindowParams.y = y - this.mDragPoint + this.mCoordOffset;

    this.mWindowParams.height = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    this.mWindowParams.width = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
    this.mWindowParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    this.mWindowParams.format = PixelFormat.TRANSLUCENT;
    this.mWindowParams.windowAnimations = 0;

    ImageView v = new ImageView(this.getContext());
    // int backGroundColor =
    // getContext().getResources().getColor(R.color.dragndrop_background);
    v.setBackgroundColor(this.dragndropBackgroundColor);
    v.setImageBitmap(bm);
    this.mDragBitmap = bm;

    this.mWindowManager = (WindowManager) this.getContext().getSystemService("window");
    this.mWindowManager.addView(v, this.mWindowParams);
    this.mDragView = v;
  }
コード例 #16
0
  /**
   * This simple implementation creates a Bitmap copy of the list item currently shown at ListView
   * <code>position</code>.
   */
  @Override
  public View onCreateFloatView(int position) {
    // Guaranteed that this will not be null? I think so. Nope, got
    // a NullPointerException once...
    View v =
        mListView.getChildAt(
            position + mListView.getHeaderViewsCount() - mListView.getFirstVisiblePosition());

    if (v == null) {
      return null;
    }

    v.setPressed(false);

    // Create a copy of the drawing cache so that it does not get
    // recycled by the framework when the list tries to clean up memory
    // v.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    v.setDrawingCacheEnabled(true);
    mFloatBitmap = Bitmap.createBitmap(v.getDrawingCache());
    v.setDrawingCacheEnabled(false);

    if (mImageView == null) {
      mImageView = new ImageView(mListView.getContext());
    }
    mImageView.setBackgroundColor(mFloatBGColor);
    mImageView.setPadding(0, 0, 0, 0);
    mImageView.setImageBitmap(mFloatBitmap);
    mImageView.setLayoutParams(new ViewGroup.LayoutParams(v.getWidth(), v.getHeight()));

    return mImageView;
  }
コード例 #17
0
  private void addDivider(boolean iOSStylable) {
    ImageView divider = new ImageView(mContext);
    divider.setScaleType(ScaleType.FIT_XY);
    divider.setBackgroundColor(getResources().getColor(R.color.setting_view_item_bg_normal));
    divider.setImageResource(R.drawable.divider);

    LayoutParams lps = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lps.gravity = Gravity.RIGHT;

    if (iOSStyleable) {
      int paddingLeft =
          (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_PX,
                      getResources().getDimensionPixelSize(R.dimen.setting_view_min_height),
                      getResources().getDisplayMetrics())
              + (int)
                  TypedValue.applyDimension(
                      TypedValue.COMPLEX_UNIT_PX,
                      getResources().getDimensionPixelSize(R.dimen.setting_view_lr_padding),
                      getResources().getDisplayMetrics());
      divider.setPadding(paddingLeft, 0, 0, 0);
    }

    addView(divider, lps);
  }
コード例 #18
0
ファイル: MainActivity.java プロジェクト: lpjhblpj/football
 public void onEventMainThread(SubscriptionFavSettingActivity.MajorTeamEvent event) {
   if (event != null) {
     majorTeamGsonModel = event.model;
     if (majorTeamGsonModel != null && !TextUtils.isEmpty(majorTeamGsonModel.avatar)) {
       File file =
           DiskCacheUtils.findInCache(majorTeamGsonModel.avatar, imageLoader.getDiskCache());
       if (file == null || !file.exists()) {
         imageLoader.displayImage(majorTeamGsonModel.avatar, majorImageView, options);
       } else {
         majorImageView.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()));
       }
     } else {
       if (mFragment instanceof FeedFragment) {
         if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
           majorImageView.setImageResource(R.drawable.tab_center_notset_pressed);
         } else {
           majorImageView.setImageResource(R.drawable.tab_center_selected);
         }
       } else {
         if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
           majorImageView.setImageResource(R.drawable.tab_center_notset_normal);
         } else {
           majorImageView.setImageResource(R.drawable.tab_center_normal);
         }
       }
     }
     if (mFragment instanceof FeedFragment) {
       if (majorTeamGsonModel != null && !TextUtils.isEmpty(majorTeamGsonModel.color))
         majorImageView.setBackgroundColor(Color.parseColor(majorTeamGsonModel.color));
       else majorImageView.setBackgroundResource(R.color.title);
     } else majorImageView.setBackgroundResource(R.color.main_tab_center);
   }
 }
コード例 #19
0
  private void startDragging(Bitmap bm, int x, int y) {
    stopDragging();

    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowParams.x = x;
    mWindowParams.y = y - mDragPoint + mCoordOffset;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    mWindowParams.windowAnimations = 0;

    ImageView v = new ImageView(getContext());
    //        int backGroundColor =
    // getContext().getResources().getColor(R.color.dragndrop_background);
    v.setBackgroundColor(dragndropBackgroundColor);
    v.setImageBitmap(bm);
    mDragBitmap = bm;

    mWindowManager = (WindowManager) getContext().getSystemService("window");
    mWindowManager.addView(v, mWindowParams);
    mDragView = v;
  }
コード例 #20
0
ファイル: PageView.java プロジェクト: muchenshou/HorseReader
  public PageView(Context context) {
    super(context);
    _uihandler = new Handler(Looper.getMainLooper());
    _animationView = new SimpleAnimationView(context, this);

    _textView = new TextView(context);
    _textView.setTextColor(Color.BLACK);
    _textView.setGravity(Gravity.LEFT);
    _textView.setPadding(20, 0, 0, 0);
    _textView.setText("" + _pageindex);

    _timeView = new TextView(context);

    _timeView.setTextColor(Color.BLACK);
    _timeView.setGravity(Gravity.RIGHT);
    _timeView.setPadding(0, 0, 20, 0);
    _timer = new Timer();
    _timer.schedule(new TimeViewTimerTask(), 1000, 2000);

    _batteryview = new ImageView(context);
    _batteryview.setBackgroundColor(Color.TRANSPARENT);
    Bitmap b = Bitmap.createBitmap(100, 50, Config.ARGB_8888);

    BitmapUtil.DrawBatteryBitmap(b, 0, 0);
    _batteryview.setImageBitmap(b);
    addView(_animationView);
    addView(_textView);
    addView(_timeView);
    addView(_batteryview);
  }
コード例 #21
0
 /*
  * (non-Javadoc)
  *
  * @see android.widget.ViewSwitcher.ViewFactory#makeView()
  */
 public View makeView() {
   final ImageView i = new ImageView(mContext);
   i.setBackgroundColor(0xff000000);
   i.setScaleType(ImageView.ScaleType.CENTER_CROP);
   i.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
   return i;
 }
コード例 #22
0
  public boolean showThumbnail() {
    if (evercamCamera.hasThumbnailUrl()) {
      Picasso.with(context).load(evercamCamera.getThumbnailUrl()).fit().into(snapshotImageView);

      if (!evercamCamera.isActive()) {
        showGreyImage();
        showOfflineIcon();
      }

      // TODO: Remove this (Disabled thumbnail saving because it uses too much memory)
      //            //Save the thumbnail, it will be showing before live view get loaded
      //            new Thread(new SaveImageRunnable(context, evercamCamera.getThumbnailUrl(),
      //                    evercamCamera.getCameraId())).start();

      return true;
    } else {
      showOfflineIcon();
      offlineImage.setVisibility(View.VISIBLE);
      snapshotImageView.setBackgroundColor(Color.GRAY);
      gradientLayout.removeGradientShadow();
      CameraLayout.this.evercamCamera.loadingStatus = ImageLoadingStatus.live_not_received;
      handler.postDelayed(LoadImageRunnable, 0);
    }
    return false;
  }
  private void startDragging(Bitmap bm, int x, int y) {
    stopDragging();

    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowParams.x = x;
    mWindowParams.y = y - mDragPoint + mCoordOffset;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    mWindowParams.windowAnimations = 0;

    Context context = getContext();
    ImageView v = new ImageView(context);
    int backGroundColor = context.getResources().getColor(android.R.color.holo_blue_dark);
    v.setAlpha((float) 0.7);
    v.setBackgroundColor(backGroundColor);
    v.setImageBitmap(bm);
    mDragBitmap = bm;

    mWindowManager = (WindowManager) context.getSystemService("window");
    mWindowManager.addView(v, mWindowParams);
    mDragView = v;
  }
コード例 #24
0
  @Override
  protected void onCreate(Bundle state) {
    super.onCreate(state);

    setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR);

    String qrData = getIntent().getStringExtra(Intent.EXTRA_TEXT);

    cameraView = new CameraView(this);
    cameraBorder = new LinearLayout(this);
    cameraBorder.setGravity(CENTER);
    cameraBorder.setBackgroundColor(BLACK);
    cameraBorder.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f));
    cameraBorder.addView(cameraView);

    ImageView qrCodeView = new ImageView(this);

    qrCodeView.setScaleType(FIT_CENTER);
    qrCodeView.setBackgroundColor(WHITE);
    qrCodeView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f));

    Display display = getWindowManager().getDefaultDisplay();
    boolean portrait = display.getWidth() < display.getHeight();
    layoutMain = new LinearLayout(this);
    if (portrait) layoutMain.setOrientation(VERTICAL);
    else layoutMain.setOrientation(HORIZONTAL);
    layoutMain.setWeightSum(2);
    layoutMain.addView(cameraBorder);
    layoutMain.addView(qrCodeView);
    setContentView(layoutMain);

    new QrGenAsyncTask(this, qrCodeView).execute(qrData);
  }
コード例 #25
0
 @Override
 public void OnImageClick(ImageView imageView) {
   biggerPicture.setImageDrawable(imageView.getDrawable());
   biggerPicture.setVisibility(View.VISIBLE);
   biggerPicture.setBackgroundColor(
       ContextCompat.getColor(context, R.color.transparent_85_percent_black));
 }
コード例 #26
0
  /** Crystal: add the plus button to the bottom bar */
  public void plusButtonSetUp(int position) {
    LinearLayout bottomBar = (LinearLayout) findViewById(R.id.bottom_bar);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(Values.privateSpaceButtonW, Values.privateSpaceButtonW);
    lp.setMargins(0, 0, Values.iconBorderPaddingH, 0);
    ImageView plus =
        PrivateSpaceIconView.plusSpaceButton(getResources().getColor(R.color.off_white), this);
    plus.setBackgroundColor(getResources().getColor(R.color.dark_grey));

    plus.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO NORA - might need to change to mainspace in Space class
            try {
              // Space.getMainSpace().getSpaceController().addSpace(Space.getMainSpace().getContext());
              Space newSpace = SpaceController.addSpace(Space.getMainSpace().getContext());
              PrivateSpaceIconView psIcon =
                  new PrivateSpaceIconView(Space.getMainSpace().getContext(), newSpace);
              newSpace.getSpaceController().setPSIV(psIcon);
            } catch (XMPPException e) {
              Log.d("MainApplication plusButtonSetUp()", "Could not add a Space");
            }
            // MainApplication.this.init_createPrivateSpace(false);
          }
        });
    bottomBar.addView(plus, position, lp);
    bottomBar.invalidate();
  }
コード例 #27
0
  @Override
  public Object instantiateItem(ViewGroup container, int position) {

    int resId = resIds[position];
    View v;

    try {
      String type = activity.getResources().getResourceTypeName(resId);
      if ("layout".equals(type)) {
        v = activity.getLayoutInflater().inflate(resId, null);
      } else if ("drawable".equals(type) || "color".equals(type)) {
        ImageView imageView = new ImageView(activity);
        imageView.setImageResource(resId);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        v = imageView;
      } else if ("string".equals(type)) {
        TextView tv = new TextView(activity);
        tv.setGravity(Gravity.CENTER);
        tv.setText(resId);
        v = tv;
      } else {
        throw new RuntimeException("unSupport type:" + type);
      }
    } catch (Resources.NotFoundException e) {
      ImageView imageView = new ImageView(activity);
      imageView.setBackgroundColor(resId);
      v = imageView;
    }

    container.addView(v);
    return v;
  }
コード例 #28
0
  private void startDragging(Bitmap bm, int x, int y) {
    stopDragging();

    mWindowParams = new WindowManager.LayoutParams();
    mWindowParams.gravity = Gravity.TOP | Gravity.LEFT;
    mWindowParams.x = x - mDragPointX + mXOffset;
    mWindowParams.y = y - mDragPointY + mYOffset;

    mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    mWindowParams.flags =
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
            | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
            | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
    mWindowParams.format = PixelFormat.TRANSLUCENT;
    mWindowParams.windowAnimations = 0;

    Context context = getContext();
    ImageView v = new ImageView(context);
    // int backGroundColor = context.getResources().getColor(R.color.dragndrop_background);

    v.setBackgroundColor(0x882211); // !!toa
    // v.setBackgroundResource(R.drawable.playlist_tile_drag);
    v.setPadding(0, 0, 0, 0);
    v.setImageBitmap(bm);
    mDragBitmap = bm;

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    mWindowManager.addView(v, mWindowParams);
    mDragView = v;
  }
コード例 #29
0
  public synchronized void fillFreeList(int animationLen) {
    final Context ctx = getContext();
    final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(mCellSize, mCellSize);

    while (!mFreeList.isEmpty()) {
      Point pt = mFreeList.iterator().next();
      mFreeList.remove(pt);
      final int i = pt.x;
      final int j = pt.y;

      if (mCells[j * mColumns + i] != null) continue;
      final ImageView v = new ImageView(ctx);
      v.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View view) {
              place(v, true);
              postDelayed(
                  new Runnable() {
                    public void run() {
                      fillFreeList();
                    }
                  },
                  DURATION / 2);
            }
          });

      final int c = random_color();
      v.setBackgroundColor(c);

      final float which = frand();
      final Drawable d;
      if (which < 0.0005f) {
        d = mDrawables.get(pick(XXRARE_PASTRIES));
      } else if (which < 0.005f) {
        d = mDrawables.get(pick(XRARE_PASTRIES));
      } else if (which < 0.5f) {
        d = mDrawables.get(pick(RARE_PASTRIES));
      } else if (which < 0.7f) {
        d = mDrawables.get(pick(PASTRIES));
      } else {
        d = null;
      }
      if (d != null) {
        v.getOverlay().add(d);
      }

      lp.width = lp.height = mCellSize;
      addView(v, lp);
      place(v, pt, false);
      if (animationLen > 0) {
        final float s = (Integer) v.getTag(TAG_SPAN);
        v.setScaleX(0.5f * s);
        v.setScaleY(0.5f * s);
        v.setAlpha(0f);
        v.animate().withLayer().scaleX(s).scaleY(s).alpha(1f).setDuration(animationLen);
      }
    }
  }
コード例 #30
0
 // if the image is upvoted by the user is green, if downvoted is red and if neutral is dark grey
 private void setBackgroundVoteColor(ImageView imageView, BaseGalleryImage image) {
   if (image.getVote() != null) {
     switch (image.getVote()) {
       case "up":
         imageView.setBackgroundColor(
             ImgurApp.getContext().getResources().getColor(R.color.imgur_green));
         break;
       case "down":
         imageView.setBackgroundColor(
             ImgurApp.getContext().getResources().getColor(R.color.imgur_red));
         break;
     }
   } else {
     imageView.setBackgroundColor(
         ImgurApp.getContext().getResources().getColor(R.color.imgur_dark_grey));
   }
 }