-
Notifications
You must be signed in to change notification settings - Fork 159
дз custom view #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
magendich
wants to merge
3
commits into
Otus-Android:master
Choose a base branch
from
magendich:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
дз custom view #119
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,21 @@ | ||
| FROM eclipse-temurin:17-jdk-jammy | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. пробовали его использовать? Мне кажется что будет ругаться на недостачу пакетов |
||
|
|
||
| ENV ANDROID_SDK_ROOT /opt/android-sdk | ||
| ENV PATH $PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools | ||
|
|
||
| RUN apt-get update && \ | ||
| apt-get install -y wget unzip git && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN wget -O cmdline-tools.zip "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip" && \ | ||
| mkdir -p $ANDROID_SDK_ROOT/cmdline-tools && \ | ||
| unzip -q cmdline-tools.zip -d $ANDROID_SDK_ROOT/cmdline-tools && \ | ||
| mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest && \ | ||
| rm cmdline-tools.zip | ||
|
|
||
| RUN yes | sdkmanager --licenses && \ | ||
| sdkmanager "platforms;android-35" "build-tools;35.0.0" "platform-tools" | ||
|
|
||
| RUN curl -Ls "https://sh.jbang.dev" | bash -s - app install --fresh --force jbang | ||
|
|
||
| WORKDIR /app | ||
This file contains hidden or 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,69 @@ | ||
| pipeline { | ||
| agent { | ||
| dockerfile true | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. нужно указать название image и параметры |
||
| } | ||
| parameters { | ||
| booleanParam(name: 'RUN_PROFILER', defaultValue: false, description: 'Запустить gradle-profiler для анализа производительности сборки?') | ||
| } | ||
|
|
||
| stages { | ||
| stage('Checkout') { | ||
| steps { | ||
| checkout scm | ||
| } | ||
| } | ||
|
|
||
| stage('Grant execution permission') { | ||
| steps { | ||
| sh 'chmod +x gradlew' | ||
| } | ||
| } | ||
|
|
||
| stage('Build') { | ||
| steps { | ||
| script { | ||
| if (env.BRANCH_NAME == 'master') { | ||
| echo "Building for master branch..." | ||
| sh './gradlew assembleRelease' | ||
| } else { | ||
| echo "Building for branch ${env.BRANCH_NAME}..." | ||
| sh './gradlew assembleDebug' | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| stage('Unit Tests') { | ||
| steps { | ||
| sh './gradlew test' | ||
| } | ||
| } | ||
|
|
||
| stage('Static Analysis') { | ||
| steps { | ||
| sh './gradlew lint' | ||
| } | ||
| } | ||
|
|
||
| stage('Profiling') { | ||
| when { | ||
| // Запускать только если параметр RUN_PROFILER установлен в true | ||
| expression { params.RUN_PROFILER } | ||
| } | ||
| steps { | ||
| script { | ||
| echo "Starting Gradle profiler..." | ||
| sh "jbang dev.gradle.profiler.tool.Main --benchmark --project-dir . --scenario-file profiler.scenarios" | ||
| archiveArtifacts artifacts: 'profile-out/', followSymlinks: false | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| post { | ||
| always { | ||
| echo 'Build finished.' | ||
| cleanWs() | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
55 changes: 53 additions & 2 deletions
55
app/src/main/java/otus/homework/customview/MainActivity.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,62 @@ | ||
| package otus.homework.customview | ||
|
|
||
| import androidx.appcompat.app.AppCompatActivity | ||
| import android.os.Bundle | ||
| import android.widget.Toast | ||
| import androidx.appcompat.app.AppCompatActivity | ||
| import com.google.gson.Gson | ||
| import com.google.gson.reflect.TypeToken | ||
| import otus.homework.customview.databinding.ActivityMainBinding | ||
| import otus.homework.customview.view.PieChartView | ||
| import android.graphics.Color | ||
|
|
||
| class MainActivity : AppCompatActivity() { | ||
| private lateinit var binding: ActivityMainBinding | ||
|
|
||
| override fun onCreate(savedInstanceState: Bundle?) { | ||
| super.onCreate(savedInstanceState) | ||
| setContentView(R.layout.activity_main) | ||
| binding = ActivityMainBinding.inflate(layoutInflater) | ||
| setContentView(binding.root) | ||
|
|
||
| val data = loadExpenses() | ||
| initPieChartView(data) | ||
| initLineChartView(data) | ||
| } | ||
|
|
||
| private fun loadExpenses(): List<PriceData> { | ||
| val json = resources.openRawResource(R.raw.payload) | ||
| .bufferedReader() | ||
| .use { it.readText() } | ||
| val type = object : TypeToken<List<PriceData>>() {}.type | ||
| return Gson().fromJson(json, type) | ||
| } | ||
|
|
||
| private fun initLineChartView(data: List<PriceData>) { | ||
| binding.lineChart.setData(data, getColorsForGradient()) | ||
| } | ||
|
|
||
| private fun initPieChartView(data: List<PriceData>) { | ||
| binding.pieChart.setData(data, getColorsForGradient()) | ||
| binding.pieChart.applyCallback(object : PieChartView.Callback { | ||
| override fun onSectorClick(priceData: PriceData) { | ||
| Toast.makeText( | ||
| this@MainActivity, | ||
| "${priceData.name} - ${priceData.amount} USD", | ||
| Toast.LENGTH_SHORT | ||
| ).show() | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| private fun getColorsForGradient() = listOf( | ||
| Color.RED to Color.rgb(255, 165, 0), | ||
| Color.BLUE to Color.CYAN, | ||
| Color.rgb(138, 43, 226) to Color.rgb(255, 105, 180), | ||
| Color.GREEN to Color.rgb(50, 205, 50), | ||
| Color.YELLOW to Color.rgb(255, 215, 0), | ||
| Color.rgb(255, 0, 0) to Color.rgb(255, 182, 193), | ||
| Color.rgb(64, 224, 208) to Color.rgb(0, 191, 255), | ||
| Color.BLACK to Color.rgb(169, 169, 169), | ||
| Color.rgb(0, 0, 139) to Color.rgb(135, 206, 250), | ||
| Color.rgb(128, 0, 128) to Color.rgb(230, 230, 250) | ||
| ).shuffled() | ||
| } |
This file contains hidden or 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,9 @@ | ||
| package otus.homework.customview | ||
|
|
||
| data class PriceData( | ||
| val id: Long, | ||
| val name: String, | ||
| val amount: Long, | ||
| val category: String, | ||
| val time: Long, | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не будет ли контейнер больше, чем при openjdk?