Skip to content

Commit

Permalink
Commit for preparing jitPack
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaval Solanki committed Apr 25, 2019
1 parent 56600b0 commit 6b23a10
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.tristate.radarsample">

<application
Expand All @@ -8,7 +9,9 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
48 changes: 48 additions & 0 deletions app/src/main/java/com/tristate/radarsample/BitmapUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.tristate.radarsample;

import android.graphics.Bitmap;
import android.graphics.Point;

import java.util.LinkedList;
import java.util.Queue;

public class BitmapUtil {
public static void floodFill(Bitmap image, Point node, int targetColor,
int replacementColor) {
int width = image.getWidth();
int height = image.getHeight();
int target = targetColor;
int replacement = replacementColor;
if (target != replacement) {
Queue<Point> queue = new LinkedList<Point>();
do {
int x = node.x;
int y = node.y;
while (x > 0 && image.getPixel(x - 1, y) == target) {
x--;
}
boolean spanUp = false;
boolean spanDown = false;
while (x < width && image.getPixel(x, y) == target) {
image.setPixel(x, y, replacement);
if (!spanUp && y > 0 && image.getPixel(x, y - 1) == target) {
queue.add(new Point(x, y - 1));
spanUp = true;
} else if (spanUp && y > 0
&& image.getPixel(x, y - 1) != target) {
spanUp = false;
}
if (!spanDown && y < height - 1
&& image.getPixel(x, y + 1) == target) {
queue.add(new Point(x, y + 1));
spanDown = true;
} else if (spanDown && y < height - 1
&& image.getPixel(x, y + 1) != target) {
spanDown = false;
}
x++;
}
} while ((node = queue.poll()) != null);
}
}
}
10 changes: 7 additions & 3 deletions app/src/main/java/com/tristate/radarsample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
public class MainActivity extends AppCompatActivity {
ArrayList<ObjectModel> mDataSet = new ArrayList<>();
private LatLongCs mLatCenter = new LatLongCs(23.0663701, 72.5295074);
RadarViewC radarConstraintViewView;
RadarViewC mRadarCustom;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRadarCustom=(RadarViewC)findViewById(R.id.mRadarCustom);
animateRadar();
loadTempData();

}

private void animateRadar() {
Expand Down Expand Up @@ -71,9 +75,9 @@ private void loadTempData() {
mDataSet.add(new ObjectModel(23.069906, 72.515504, 150, t3));
mDataSet.add(new ObjectModel(23.069608, 72.516477, 150, t4));
mDataSet.add(new ObjectModel(23.069213, 72.517739, 100, t5));
radarConstraintViewView.setupData(250, mDataSet, latLongCs, mCenterView);
mRadarCustom.setupData(250, mDataSet, latLongCs, mCenterView);

radarConstraintViewView.setUpCallBack(new RadarViewC.IRadarCallBack() {
mRadarCustom.setUpCallBack(new RadarViewC.IRadarCallBack() {
@Override
public void onViewClick(Object objectModel, View view) {

Expand Down
84 changes: 84 additions & 0 deletions app/src/main/java/com/tristate/radarsample/PaintActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.tristate.radarsample;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.media.Image;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;

public class PaintActivity extends AppCompatActivity implements View.OnTouchListener {

private ImageView mImgSource;

@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_paint);
mImgSource = (ImageView) findViewById(R.id.mImgSource);
mImgSource.setOnTouchListener(this);
}

@Override
public boolean onTouch(View v, MotionEvent event) {

switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:

break;
case MotionEvent.ACTION_UP:
float x = event.getX();
float y = event.getY();

final Point p1 = new Point();
p1.x = (int) x; //x co-ordinate where the user touches on the screen
p1.y = (int) y; //y co-ordinate where the user touches on the screen
Bitmap bitmap = ((BitmapDrawable) mImgSource.getDrawable()).getBitmap();
final int sourceColor = bitmap.getPixel((int) x, (int) y);
new ColorFillOpt(bitmap, p1, Color.parseColor("#D81B60"), sourceColor).doInBackground();
break;
}
return true;
}

@Override
public void onPointerCaptureChanged(boolean hasCapture) {

}

public class ColorFillOpt extends AsyncTask<Void, Void, Void> {

private final Bitmap bitmap;
private final Point p1;
private final int titleColor;
private final int sourceColor;

public ColorFillOpt(Bitmap bitmap, Point p1, int titleColor, int sourceColor) {
this.bitmap = bitmap;
this.p1 = p1;
this.titleColor = titleColor;
this.sourceColor = sourceColor;
}

@Override
protected Void doInBackground(Void... voids) {
BitmapUtil.floodFill(bitmap, p1, getTitleColor(), sourceColor);
return null;
}

@Override
protected void onPostExecute(Void aVoid) {
mImgSource.setImageBitmap(bitmap);
super.onPostExecute(aVoid);

}
}
}
Binary file added app/src/main/res/drawable/wall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions app/src/main/res/layout/activity_paint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PaintActivity">

<ImageView
android:id="@+id/mImgSource"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/wall"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'

classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -18,7 +18,6 @@ allprojects {
repositories {
google()
jcenter()

}
}

Expand Down
2 changes: 2 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
# For customization when using a Version Control System, please read the
# header note.
sdk.dir=/home/android/Android/sdk
bintray.user= “tristatetechnology”
bintray.apikey= “86a713a5e8fd7fe3c2989774cd9a0b481cbc392d”
4 changes: 4 additions & 0 deletions radarview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='tristate.dev'
version='1.0'

android {
compileSdkVersion 28
Expand Down Expand Up @@ -32,3 +35,4 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}

0 comments on commit 6b23a10

Please sign in to comment.