List of usage examples for android.graphics Color BLACK
int BLACK
To view the source code for android.graphics Color BLACK.
Click Source Link
From source file:com.marblelab.dropbox.DBRoulette.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Firebase.setAndroidContext(this); mRef = new Firebase("https://light-and-fridge.firebaseio.com/fridge/state"); /**//from www. ja v a 2 s.c o m * new codes here */ /* DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); int height = displayMetrics.heightPixels; int width = displayMetrics.widthPixels; */ final ImagePopup imagePopup = new ImagePopup(this); imagePopup.setBackgroundColor(Color.BLACK); //Pad imagePopup.setWindowWidth(1500); imagePopup.setWindowHeight(1250); //S2 /*imagePopup.setWindowWidth(480); imagePopup.setWindowHeight(410);*/ imagePopup.setHideCloseIcon(true); imagePopup.setImageOnClickClose(true); if (savedInstanceState != null) { mCameraFileName = savedInstanceState.getString("mCameraFileName"); } // We create a new AuthSession so that we can use the Dropbox API. AndroidAuthSession session = buildSession(); mApi = new DropboxAPI<AndroidAuthSession>(session); // Basic Android widgets setContentView(R.layout.activity_main); checkAppKeySetup(); /** * old code */ mSubmit = (FloatingActionButton) findViewById(R.id.fbSubmit); mSubmit.setOnClickListener(new OnClickListener() { public void onClick(View v) { // This logs you out if you're logged in, or vice versa if (mLoggedIn) { logOut(); } else { // Start the remote authentication if (USE_OAUTH1) { mApi.getSession().startAuthentication(DBRoulette.this); } else { mApi.getSession().startOAuth2Authentication(DBRoulette.this); } } } }); //mDisplay = (LinearLayout)findViewById(R.id.logged_in_display); // This is where a photo is displayed mImage = (ImageView) findViewById(R.id.image_view); mImageSecond = (ImageView) findViewById(R.id.image_second); mImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { imagePopup.initiatePopup(mImage.getDrawable()); } }); mImageSecond.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { imagePopup.initiatePopup(mImageSecond.getDrawable()); } }); // This is the button to take a photo /* mPhoto = (Button)findViewById(R.id.photo_button); mPhoto.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); // Picture from camera intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); // This is not the right way to do this, but for some reason, having // it store it in // MediaStore.Images.Media.EXTERNAL_CONTENT_URI isn't working right. Date date = new Date(); DateFormat df = new SimpleDateFormat("yyyy-MM-dd-kk-mm-ss", Locale.US); String newPicFile = df.format(date) + ".jpg"; String outPath = new File(Environment.getExternalStorageDirectory(), newPicFile).getPath(); File outFile = new File(outPath); mCameraFileName = outFile.toString(); Uri outuri = Uri.fromFile(outFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, outuri); Log.i(TAG, "Importing New Picture: " + mCameraFileName); try { startActivityForResult(intent, NEW_PICTURE); } catch (ActivityNotFoundException e) { showToast("There doesn't seem to be a camera."); } } }); */ // This is the button to take a photo mRoulette = (SwipeRefreshLayout) findViewById(R.id.roulette_button); mPullText1 = (TextView) findViewById(R.id.tvPullText1); mPullText2 = (TextView) findViewById(R.id.tvPullText2); mRoulette.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mRef.setValue("send"); //TODO implements a 3-5 sec wait commands or methods new CountDownTimer(15000, 1000) { public void onTick(long millisUntilFinished) { mPullText1.setText("Waiting : " + millisUntilFinished / 1000); mPullText2.setText("Waiting: " + millisUntilFinished / 1000); } public void onFinish() { mPullText1.setText("Camera One"); mPullText2.setText("Camera Two"); DownloadRandomPicture download = new DownloadRandomPicture(DBRoulette.this, mApi, PHOTO_DIR, mImage, 2); download.execute(); DownloadRandomPicture downloadSecond = new DownloadRandomPicture(DBRoulette.this, mApi, PHOTO_DIR, mImageSecond, 1); downloadSecond.execute(); } }.start(); } }); /** * new codes here */ // Display the proper UI state if logged in or not setLoggedIn(mApi.getSession().isLinked()); }
From source file:alexander.martinz.libs.materialpreferences.MaterialPreference.java
public boolean init(Context context, AttributeSet attrs) { if (mInit) {//from ww w. j a va2s. co m return false; } mInit = true; if (attrs != null) { TypedArray typedArray = parseAttrs(context, attrs); recycleTypedArray(typedArray); } final int layoutResId = mPrefAsCard ? R.layout.material_prefs_card_preference : R.layout.material_prefs_preference; mView = getLayoutInflater().inflate(layoutResId, this, true); if (mPrefAsCard) { mCardView = (CardView) mView.findViewById(R.id.card_preference_root); } mIcon = (ImageView) mView.findViewById(android.R.id.icon); mTitle = (TextView) mView.findViewById(android.R.id.title); mSummary = (TextView) mView.findViewById(android.R.id.summary); mWidgetFrame = (LinearLayout) mView.findViewById(android.R.id.widget_frame); mWidgetFrameBottom = (LinearLayout) mView.findViewById(R.id.widget_frame_bottom); if (mResIdIcon != -1 && mIcon != null) { Drawable d = ContextCompat.getDrawable(context, mResIdIcon); if (d != null && mIconTintColor != Integer.MIN_VALUE) { d = d.mutate(); d.setColorFilter(new LightingColorFilter(Color.BLACK, mIconTintColor)); } mIcon.setImageDrawable(d); mIcon.setVisibility(View.VISIBLE); } if (mResIdTitle != -1) { mTitle.setText(mResIdTitle); } if (mResIdSummary != -1 && mSummary != null) { mSummary.setText(mResIdSummary); mSummary.setVisibility(View.VISIBLE); } if (mPrefAsCard && mCardBackgroundColor != Integer.MIN_VALUE) { setBackgroundColor(mCardBackgroundColor); } setSelectable(true); setOnClickListener(this); setOnTouchListener(this); setOrientation(LinearLayout.VERTICAL); return true; }
From source file:com.discord.chipsview.ChipsView.java
private void initAttr(Context context, AttributeSet attrs) { TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ChipsView, 0, 0); try {/* ww w.ja v a 2 s .co m*/ mMaxHeight = a.getDimensionPixelSize(R.styleable.ChipsView_cv_max_height, DEFAULT_MAX_HEIGHT); mVerticalSpacing = a.getDimensionPixelSize(R.styleable.ChipsView_cv_vertical_spacing, (int) (DEFAULT_VERTICAL_SPACING * mDensity)); mChipsColor = a.getColor(R.styleable.ChipsView_cv_color, ContextCompat.getColor(context, android.R.color.darker_gray)); mChipsColorClicked = a.getColor(R.styleable.ChipsView_cv_color_clicked, ContextCompat.getColor(context, android.R.color.white)); mChipsBgColor = a.getColor(R.styleable.ChipsView_cv_bg_color, ContextCompat.getColor(context, android.R.color.white)); mChipsBgColorClicked = a.getColor(R.styleable.ChipsView_cv_bg_color_clicked, ContextCompat.getColor(context, android.R.color.holo_blue_dark)); mChipsTextColor = a.getColor(R.styleable.ChipsView_cv_text_color, Color.BLACK); mChipsTextColorClicked = a.getColor(R.styleable.ChipsView_cv_text_color_clicked, Color.WHITE); mChipsPlaceholderResId = a.getResourceId(R.styleable.ChipsView_cv_icon_placeholder, 0); mChipsDeleteResId = a.getResourceId(R.styleable.ChipsView_cv_icon_delete, R.drawable.drawable_chip_delete); mChipsSearchTextColor = a.getColor(R.styleable.ChipsView_cv_search_text_color, Color.BLACK); mChipsSearchTextSize = a.getDimensionPixelSize(R.styleable.ChipsView_cv_search_text_size, 49); mChipLayout = a.getResourceId(R.styleable.ChipsView_cv_chip_layout, R.layout.view_chip_default); } finally { a.recycle(); } }
From source file:com.mumu.pokemongogo.HeadService.java
private void initGamePanelViews() { mHeadIconList = new ArrayList<>(); // Head Icon/*from w w w . j a va2 s .c o m*/ HeadIconView headIcon = new HeadIconView(new ImageView(this), mWindowManager, 0, 0); headIcon.getImageView().setImageResource(R.mipmap.ic_launcher); headIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { configHeadIconShowing(HeadIconView.AUTO); } @Override public void onLongPress(View view) { showExitConfirmDialog(); } }); mHeadIconList.add(headIcon); // Message Text Icon HeadIconView msgText = new HeadIconView(new TextView(this), mWindowManager, 120, 13); msgText.getTextView().setText(""); msgText.getTextView().setTextColor(Color.BLACK); msgText.getView().setBackgroundColor(Color.WHITE); mHeadIconList.add(msgText); // Start Game Pad Icon HeadIconView startIcon = new HeadIconView(new ImageView(this), mWindowManager, 0, 75); startIcon.getImageView().setImageResource(R.drawable.ic_play); startIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { configFreeWalking(); } @Override public void onLongPress(View view) { } }); mHeadIconList.add(startIcon); // Home Icon HeadIconView homeIcon = new HeadIconView(new ImageView(this), mWindowManager, 80, 90); homeIcon.getImageView().setImageResource(R.drawable.ic_location_pin); homeIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { Log.d(TAG, "config map icon"); mFakeLocationManager.cancelAutoPilot(); configHeadIconShowing(HeadIconView.INVISIBLE); Intent mapIntent = new Intent(mContext, MapLocationViewer.class); mapIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(mapIntent); } @Override public void onLongPress(View view) { } }); mHeadIconList.add(homeIcon); // Incubator Icon HeadIconView incubatorIcon = new HeadIconView(new ImageView(this), mWindowManager, 150, 90); incubatorIcon.getImageView().setImageResource(R.drawable.ic_egg_disabled); incubatorIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { Log.d(TAG, "config auto incubating"); configAutoIncubating(); } @Override public void onLongPress(View view) { } }); mHeadIconList.add(incubatorIcon); // Speed control Icon HeadIconView speedIcon = new HeadIconView(new ImageView(this), mWindowManager, 220, 85); speedIcon.getImageView().setImageResource(R.drawable.ic_one); speedIcon.setOnTapListener(new HeadIconView.OnTapListener() { @Override public void onTap(View view) { Log.d(TAG, "config speed"); if (!mAutoIncubating) configSpeed(); else mMessageText = "You can't"; } @Override public void onLongPress(View view) { } }); mHeadIconList.add(speedIcon); // Share the same on move listener for moving in the same time HeadIconView.OnMoveListener moveListener = new HeadIconView.OnMoveListener() { @Override public void onMove(int initialX, int initialY, float initialTouchX, float initialTouchY, MotionEvent event) { for (HeadIconView icon : mHeadIconList) { icon.moveIconDefault(initialX, initialY, initialTouchX, initialTouchY, event); } } }; // Set all to add for (HeadIconView icon : mHeadIconList) { icon.addView(); icon.setOnMoveListener(moveListener); } // Set default visibility mHeadIconList.get(IDX_START_ICON).setVisibility(View.INVISIBLE); mHeadIconList.get(IDX_HOME_ICON).setVisibility(View.INVISIBLE); mHeadIconList.get(IDX_INCUBATOR_ICON).setVisibility(View.INVISIBLE); mHeadIconList.get(IDX_SPEED_ICON).setVisibility(View.INVISIBLE); }
From source file:it.unipr.ce.dsg.gamidroid.activities.SensorDataViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sensor_data); mContext = this; overridePendingTransition(R.anim.animate_left_in, R.anim.animate_left_out); Button backButton = (Button) findViewById(R.id.backButtonSensor); backButton.setOnClickListener(new View.OnClickListener() { @Override/*from ww w . j a v a 2s . c o m*/ public void onClick(View v) { stopThread(); GamiNode.getAndroidGamiNode(mContext).getRfm().stopTemperatureNotificationLookup(); onBackPressed(); } }); stopThread = false; Bundle b = getIntent().getExtras(); location = new Location(); location.setBuilding(new Building(b.getString("Building"))); location.setFloor(new Floor(b.getString("Floor"))); location.setRoom(new Room(b.getString("Room"))); location.setSensor(new Sensor(b.getString("Sensor"))); sensorName = b.getString("Sensor"); String buildingToShow = b.getString("Building"); if (buildingToShow.length() > 28) buildingToShow = buildingToShow.substring(0, 28) + "..."; String floorToShow = getResources().getString(R.string.floor) + b.getString("Floor"); if (floorToShow.length() > 28) floorToShow = floorToShow.substring(0, 28) + "..."; String roomToShow = b.getString("Room"); if (roomToShow.length() > 28) roomToShow = roomToShow.substring(0, 28) + "..."; titleTv = (TextView) findViewById(R.id.SensorResumeText); titleTv.setText(buildingToShow + "\n" + floorToShow + "\n" + roomToShow); titleTv.setTextSize(15); GamiNode.getAndroidGamiNode(mContext).getRfm().startTemperatureNotificationLookup( location.getBuilding().getValue(), location.getFloor().getValue(), location.getRoom().getValue(), location.getSensor().getValue()); SharedPreferences sharedPreferences = mContext.getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE); String currentNetwork = sharedPreferences.getString(Constants.NETWORK, ""); if (currentNetwork.equalsIgnoreCase(Constants.CHORD)) { GamiNode.addChordResourceListener(this); } else if (currentNetwork.equalsIgnoreCase(Constants.MESH)) { GamiNode.addMeshResourceListener(this); } // Initialize sensor data graph graphViewSeries = new GraphViewSeries(new GraphViewData[] {}); graphView = new LineGraphView(this, "Sensor Readings"); graphView.setPadding(3, 0, 0, 0); graphView.getGraphViewStyle().setGridColor(Color.BLACK); graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.BLACK); graphView.getGraphViewStyle().setVerticalLabelsColor(Color.BLACK); graphView.getGraphViewStyle().setTextSize(16); graphView.getGraphViewStyle().setVerticalLabelsWidth(40); // width of the vertical labels Date d = new Date(); String s = (String) DateFormat.format("H:m:s ", d.getTime()); System.out.println(s); // Array of strings that are the horizontal labels hLabels = new String[] { s }; graphView.setHorizontalLabels(hLabels); // graphView.getGraphViewStyle().setVerticalLabelsWidth(200); graphView.addSeries(graphViewSeries); // data graphView.setViewPort(0, 4); graphView.setScalable(false); graphView.setScrollable(true); graphView.setManualYAxisBounds(45, 0); // graphView.getGraphViewStyle().setNumVerticalLabels(45 / 5); graphView.getGraphViewStyle().setNumHorizontalLabels(10); layout = (LinearLayout) findViewById(R.id.graph); layout.addView(graphView); }
From source file:com.android.demos.module.animation.materialloadingprogressbar.CircleProgressBar.java
private void init(Context context, AttributeSet attrs, int defStyleAttr) { final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleProgressBar, defStyleAttr, 0); // <attr name="mlpb_inner_radius" format="dimension"/> // <attr name="mlpb_background_color" format="color"/> // <attr name="mlpb_progress_color" format="color"/> // <attr name="mlpb_progress_stoke_width" format="dimension"/> // <attr name="mlpb_arrow_width" format="dimension"/> // <attr name="mlpb_arrow_height" format="dimension"/> ///*from w w w. j a va2 s . c o m*/ // <attr name="mlpb_progress" format="integer"/> // <attr name="mlpb_max" format="integer"/> // // // <attr name="mlpb_progress_text_size" format="dimension"/> // <attr name="mlpb_progress_text_color" format="color"/> // // <attr name="mlpb_progress_text_offset" format="dimension"/> // // <attr name="mlpb_progress_text_visibility" format="enum"> // <enum name="visible" value="0"/> // <enum name="invisible" value="1"/> // </attr> final float density = getContext().getResources().getDisplayMetrics().density; mBackGroundColor = a.getColor(R.styleable.CircleProgressBar_mlpb_background_color, DEFAULT_CIRCLE_BG_LIGHT); mProgressColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_color, DEFAULT_CIRCLE_BG_LIGHT);//ToDO mInnerRadius = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_inner_radius, -1); mProgressStokeWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_stoke_width, (int) (STROKE_WIDTH_LARGE * density)); mArrowWidth = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_width, -1); mArrowHeight = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_arrow_height, -1); mTextSize = a.getDimensionPixelOffset(R.styleable.CircleProgressBar_mlpb_progress_text_size, (int) (DEFAULT_TEXT_SIZE * density)); mTextColor = a.getColor(R.styleable.CircleProgressBar_mlpb_progress_text_color, Color.BLACK); mShowArrow = a.getBoolean(R.styleable.CircleProgressBar_mlpb_show_arrow, false); mCircleBackgroundEnabled = a.getBoolean(R.styleable.CircleProgressBar_mlpb_enable_circle_background, true); mProgress = a.getInt(R.styleable.CircleProgressBar_mlpb_progress, 0); mMax = a.getInt(R.styleable.CircleProgressBar_mlpb_max, 100); int textVisible = a.getInt(R.styleable.CircleProgressBar_mlpb_progress_text_visibility, 1); if (textVisible != 1) { mIfDrawText = true; } mTextPaint = new Paint(); mTextPaint.setStyle(Paint.Style.FILL); mTextPaint.setColor(mTextColor); mTextPaint.setTextSize(mTextSize); mTextPaint.setAntiAlias(true); a.recycle(); mProgressDrawable = new MaterialProgressDrawable(getContext(), this); super.setImageDrawable(mProgressDrawable); }
From source file:com.blockhead.gussilva.threemorewords.GameActivity.java
public void letterPressed(View view) { String ltr = ((TextView) view).getText().toString(); char letterChar = ltr.charAt(0); view.setEnabled(false);//from w w w . j a v a 2 s . c o m view.setBackgroundResource(R.drawable.letter_down); //Check if it is a correct guess boolean correct = false; //Check Word 1 for (int k = 0; k < currWord1.length(); k++) { if (currWord1.charAt(k) == letterChar) { correct = true; numCorr++; answerViews1[k].setTextColor(Color.BLACK); } } //Check Word 2 for (int k = 0; k < currWord2.length(); k++) { if (currWord2.charAt(k) == letterChar) { correct = true; numCorr++; answerViews2[k].setTextColor(Color.BLACK); } } //Check Word 3 for (int k = 0; k < currWord3.length(); k++) { if (currWord3.charAt(k) == letterChar) { correct = true; numCorr++; answerViews3[k].setTextColor(Color.BLACK); } } //Check if user has won, lost, or can continue playing if (correct) { //correct guess if (numCorr == numChars) { // Disable Buttons disableBtns(); // Display Alert Dialog AlertDialog.Builder winBuild = new AlertDialog.Builder(this); winBuild.setTitle("Success"); winBuild.setMessage( "You win!\n\nThe answers were:\n" + currWord1 + "\n" + currWord2 + "\n" + currWord3); winBuild.setPositiveButton("Play Again", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { GameActivity.this.playGame(); } }); winBuild.setNegativeButton("Exit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { GameActivity.this.finish(); } }); winBuild.show(); } } else if (currWrong < numChances) { //User still has chances currWrong++; view.setBackgroundResource(R.drawable.letter_wrong); if ((numChances - currWrong) > 1) chancesLeftView.setText((numChances - currWrong) + " chances left"); else if ((numChances - currWrong) == 1) chancesLeftView.setText("1 chance left"); else chancesLeftView.setText("Last Chance!"); if (currWrong == 3) { chancesLeftView.setTextColor(getResources().getColor(R.color.chances_medium)); } else if (currWrong == 5) { chancesLeftView.setTextColor(getResources().getColor(R.color.chances_bad)); } } else { //User has lost disableBtns(); // Display Alert Dialog AlertDialog.Builder loseBuild = new AlertDialog.Builder(this); loseBuild.setTitle("OOPS"); loseBuild.setMessage( "You lose!\n\nThe answers were:\n" + currWord1 + "\n" + currWord2 + "\n" + currWord3); loseBuild.setPositiveButton("Play Again", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { GameActivity.this.playGame(); } }); loseBuild.setNegativeButton("Exit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { GameActivity.this.finish(); } }); loseBuild.show(); } }
From source file:alaindc.crowdroid.View.StakeholdersActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_stakeholders); linearLayout = (LinearLayout) findViewById(R.id.subscribesLinearLayout); updateStakeButton = (Button) findViewById(R.id.updateStakeButton); sendStakeButton = (Button) findViewById(R.id.sendStakeButton); updateStakeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent subscrIntent = new Intent(getApplicationContext(), SendIntentService.class); subscrIntent.setAction(Constants.ACTION_GETSUBSCRIPTION); getApplicationContext().startService(subscrIntent); }//from w w w. j a v a2 s .c om }); sendStakeButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { JSONArray jsonArr = new JSONArray(); JSONObject jsonObj = new JSONObject(); jsonObj.put("user", RadioUtils.getMyDeviceId(getApplicationContext())); jsonArr.put(jsonObj); for (int i = 0; i < linearLayout.getChildCount(); i++) { View view = linearLayout.getChildAt(i); if (view instanceof CheckBox) { CheckBox c = (CheckBox) view; if (c.isChecked()) { jsonObj = new JSONObject(); jsonObj.put("id", c.getId()); jsonArr.put(jsonObj); } } } String body = jsonArr.toString(); Intent subscrIntent = new Intent(getApplicationContext(), SendIntentService.class); subscrIntent.setAction(Constants.ACTION_UPDATESUBSCRIPTION); subscrIntent.putExtra(Constants.EXTRA_BODY_UPDATESUBSCRIPTION, body); getApplicationContext().startService(subscrIntent); } catch (JSONException e) { return; } } }); Intent subscrIntent = new Intent(getApplicationContext(), SendIntentService.class); subscrIntent.setAction(Constants.ACTION_GETSUBSCRIPTION); getApplicationContext().startService(subscrIntent); BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Constants.INTENTVIEW_RECEIVED_SUBSCRIPTION)) { String response = intent.getStringExtra(Constants.EXTRAVIEW_RECEIVED_SUBSCRIPTION); //Toast.makeText(getApplicationContext(), response, Toast.LENGTH_LONG).show(); linearLayout.removeAllViews(); try { JSONArray jsonArray = new JSONArray(response); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); int id = jsonObject.getInt("id"); String name = jsonObject.getString("name"); boolean subscribed = jsonObject.getInt("subscribed") == 1; CheckBox checkBox = new CheckBox(getApplicationContext()); checkBox.setTextColor(Color.BLACK); checkBox.setText(name); checkBox.setId(id); checkBox.setChecked(subscribed); linearLayout.addView(checkBox); int idx = linearLayout.indexOfChild(checkBox); checkBox.setTag(Integer.toString(idx)); } } catch (JSONException e) { return; } } else { Log.d("", ""); } } }; IntentFilter rcvDataIntFilter = new IntentFilter(Constants.INTENTVIEW_RECEIVED_SUBSCRIPTION); LocalBroadcastManager.getInstance(this).registerReceiver(receiver, rcvDataIntFilter); }
From source file:com.htc.dotdesign.DrawingView.java
@Override public boolean onTouchEvent(MotionEvent event) { clickX = event.getX();//w w w.j a va 2 s .c o m clickY = event.getY(); int x = (int) (clickY / sDotPixelWidth); int y = (int) (clickX / sDotPixelHeight); if (isShowDotMask) { mEraseColor = Color.BLACK; } else { mEraseColor = Color.TRANSPARENT; } if (mActivity != null && mActivity.isToolBarOpen()) { Log.d(DotDesignConstants.LOG_TAG, LOG_PREFIX + "ToolBarOpen"); closeToolBar(); } if (event.getAction() == MotionEvent.ACTION_DOWN) { if ((x >= 0 && x < 48) && (y >= 0 && y < 27)) { mPreX = x; mPreY = y; if (mCurrentMode == Mode.BRUSH_1X1) { mImgDotMatrix[x][y] = mCurrBrushColor; } else if (mCurrentMode == Mode.BRUSH_2X2) { mImgDotMatrix[x][y] = mCurrBrushColor; if (y + 1 < 27) { mImgDotMatrix[x][y + 1] = mCurrBrushColor; } if (x + 1 < 48) { mImgDotMatrix[x + 1][y] = mCurrBrushColor; } if (x + 1 < 48 && y + 1 < 27) { mImgDotMatrix[x + 1][y + 1] = mCurrBrushColor; } } else if (mCurrentMode == Mode.ERASER_1X1) { mImgDotMatrix[x][y] = mEraseColor; } else if (mCurrentMode == Mode.ERASER_2X2) { mImgDotMatrix[x][y] = mEraseColor; if (y + 1 < 27) { mImgDotMatrix[x][y + 1] = mEraseColor; } if (x + 1 < 48) { mImgDotMatrix[x + 1][y] = mEraseColor; } if (x + 1 < 48 && y + 1 < 27) { mImgDotMatrix[x + 1][y + 1] = mEraseColor; } } invalidate(); return true; } } else if (event.getAction() == MotionEvent.ACTION_MOVE) { if (x != mPreX || y != mPreY) { if ((x >= 0 && x < 48) && (y >= 0 && y < 27)) { mPreX = x; mPreY = y; if (mCurrentMode == Mode.BRUSH_1X1) { mImgDotMatrix[x][y] = mCurrBrushColor; } else if (mCurrentMode == Mode.BRUSH_2X2) { mImgDotMatrix[x][y] = mCurrBrushColor; if (y + 1 < 27) { mImgDotMatrix[x][y + 1] = mCurrBrushColor; } if (x + 1 < 48) { mImgDotMatrix[x + 1][y] = mCurrBrushColor; } if (x + 1 < 48 && y + 1 < 27) { mImgDotMatrix[x + 1][y + 1] = mCurrBrushColor; } } else if (mCurrentMode == Mode.ERASER_1X1) { mImgDotMatrix[x][y] = mEraseColor; } else if (mCurrentMode == Mode.ERASER_2X2) { mImgDotMatrix[x][y] = mEraseColor; if (y + 1 < 27) { mImgDotMatrix[x][y + 1] = mEraseColor; } if (x + 1 < 48) { mImgDotMatrix[x + 1][y] = mEraseColor; } if (x + 1 < 48 && y + 1 < 27) { mImgDotMatrix[x + 1][y + 1] = mEraseColor; } } invalidate(); return true; } } } return super.onTouchEvent(event); }
From source file:android.support.wear.widget.CircularProgressLayout.java
public CircularProgressLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mProgressDrawable = new CircularProgressDrawable(context); mProgressDrawable.setProgressRotation(DEFAULT_ROTATION); mProgressDrawable.setStrokeCap(Paint.Cap.BUTT); setBackground(mProgressDrawable);/*w ww. j ava 2s.c om*/ // If a child view is added, make it center aligned so it fits in the progress drawable. setOnHierarchyChangeListener(new OnHierarchyChangeListener() { @Override public void onChildViewAdded(View parent, View child) { // Ensure that child view is aligned in center LayoutParams params = (LayoutParams) child.getLayoutParams(); params.gravity = Gravity.CENTER; child.setLayoutParams(params); } @Override public void onChildViewRemoved(View parent, View child) { } }); mController = new CircularProgressLayoutController(this); Resources r = context.getResources(); TypedArray a = r.obtainAttributes(attrs, R.styleable.CircularProgressLayout); if (a.getType(R.styleable.CircularProgressLayout_colorSchemeColors) == TypedValue.TYPE_REFERENCE || !a.hasValue(R.styleable.CircularProgressLayout_colorSchemeColors)) { int arrayResId = a.getResourceId(R.styleable.CircularProgressLayout_colorSchemeColors, R.array.circular_progress_layout_color_scheme_colors); setColorSchemeColors(getColorListFromResources(r, arrayResId)); } else { setColorSchemeColors(a.getColor(R.styleable.CircularProgressLayout_colorSchemeColors, Color.BLACK)); } setStrokeWidth(a.getDimensionPixelSize(R.styleable.CircularProgressLayout_strokeWidth, r.getDimensionPixelSize(R.dimen.circular_progress_layout_stroke_width))); setBackgroundColor(a.getColor(R.styleable.CircularProgressLayout_backgroundColor, ContextCompat.getColor(context, R.color.circular_progress_layout_background_color))); setIndeterminate(a.getBoolean(R.styleable.CircularProgressLayout_indeterminate, false)); a.recycle(); }