-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
514 additions
and
7 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
app/src/main/java/com/github/anastr/speedview/RayActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.github.anastr.speedview; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.SeekBar; | ||
import android.widget.TextView; | ||
|
||
import com.github.anastr.speedviewlib.RaySpeedometer; | ||
|
||
public class RayActivity extends AppCompatActivity { | ||
|
||
RaySpeedometer raySpeedometer; | ||
SeekBar seekBarSpeed, seekBarDegree, seekBarWidth; | ||
Button ok; | ||
TextView textSpeed, textDegree, textWidth; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_ray); | ||
|
||
raySpeedometer = (RaySpeedometer) findViewById(R.id.raySpeedometer); | ||
seekBarSpeed = (SeekBar) findViewById(R.id.seekBarSpeed); | ||
seekBarDegree = (SeekBar) findViewById(R.id.seekBarDegree); | ||
seekBarWidth = (SeekBar) findViewById(R.id.seekBarWidth); | ||
ok = (Button) findViewById(R.id.ok); | ||
textSpeed = (TextView) findViewById(R.id.textSpeed); | ||
textDegree = (TextView) findViewById(R.id.textDegree); | ||
textWidth = (TextView) findViewById(R.id.textWidth); | ||
|
||
ok.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
raySpeedometer.speedTo(seekBarSpeed.getProgress()); | ||
} | ||
}); | ||
|
||
seekBarSpeed.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | ||
@Override | ||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | ||
textSpeed.setText(String.format("%d", progress)); | ||
} | ||
|
||
@Override | ||
public void onStartTrackingTouch(SeekBar seekBar) { | ||
|
||
} | ||
|
||
@Override | ||
public void onStopTrackingTouch(SeekBar seekBar) { | ||
|
||
} | ||
}); | ||
|
||
seekBarDegree.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | ||
@Override | ||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | ||
textDegree.setText(String.format("%d", progress)); | ||
raySpeedometer.setDegreeBetweenMark(progress); | ||
} | ||
|
||
@Override | ||
public void onStartTrackingTouch(SeekBar seekBar) { | ||
} | ||
|
||
@Override | ||
public void onStopTrackingTouch(SeekBar seekBar) { | ||
} | ||
}); | ||
|
||
seekBarWidth.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | ||
@Override | ||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | ||
textWidth.setText(String.format("%d", progress) + "dp"); | ||
raySpeedometer.setMarkWidth((int) dpTOpx(progress)); | ||
} | ||
|
||
@Override | ||
public void onStartTrackingTouch(SeekBar seekBar) { | ||
} | ||
|
||
@Override | ||
public void onStopTrackingTouch(SeekBar seekBar) { | ||
} | ||
}); | ||
} | ||
|
||
float dpTOpx(float dp) { | ||
return dp * getResources().getDisplayMetrics().density; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:paddingBottom="@dimen/activity_vertical_margin" | ||
android:paddingLeft="@dimen/activity_horizontal_margin" | ||
android:paddingRight="@dimen/activity_horizontal_margin" | ||
android:paddingTop="@dimen/activity_vertical_margin" | ||
android:orientation="vertical" | ||
tools:context="com.github.anastr.speedview.RayActivity"> | ||
|
||
<com.github.anastr.speedviewlib.RaySpeedometer | ||
android:id="@+id/raySpeedometer" | ||
android:layout_width="250dp" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
app:backgroundCircleColor="#f0ff4c" | ||
app:markColor="#414141" | ||
app:textColor="#000" | ||
app:rayColor="#d8ff0000" | ||
app:lowSpeedColor="#3ada00" | ||
app:mediumSpeedColor="#ff7700" | ||
app:highSpeedColor="#ce0000" | ||
app:degreeBetweenMark="5" | ||
app:markWidth="3dp"/> | ||
|
||
<LinearLayout | ||
android:orientation="horizontal" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<SeekBar | ||
android:id="@+id/seekBarSpeed" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:max="100" | ||
android:layout_gravity="center_vertical"/> | ||
|
||
<TextView | ||
android:id="@+id/textSpeed" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textAppearance="?android:attr/textAppearanceMedium" | ||
tools:text="50" /> | ||
|
||
<Button | ||
android:id="@+id/ok" | ||
style="?android:attr/buttonStyleSmall" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="ok" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:orientation="horizontal" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="10dp"> | ||
|
||
<SeekBar | ||
android:id="@+id/seekBarDegree" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:max="20" | ||
android:layout_gravity="center_vertical"/> | ||
|
||
<TextView | ||
android:id="@+id/textDegree" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textAppearance="?android:attr/textAppearanceMedium" | ||
tools:text="50" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textAppearance="?android:attr/textAppearanceMedium" | ||
android:text=" Degree" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:orientation="horizontal" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:padding="10dp"> | ||
|
||
<SeekBar | ||
android:id="@+id/seekBarWidth" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:max="10" | ||
android:layout_gravity="center_vertical"/> | ||
|
||
<TextView | ||
android:id="@+id/textWidth" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textAppearance="?android:attr/textAppearanceMedium" | ||
tools:text="50dp" /> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textAppearance="?android:attr/textAppearanceMedium" | ||
android:text=" MarkWidth" /> | ||
</LinearLayout> | ||
|
||
</LinearLayout> |
Oops, something went wrong.