Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

Importing code into processing

$
0
0

Hi I am trying to use a color picker for my android application. I am borrowing some available code from the web however I failed at implementing the code. I am using the class ColorPickerDialog available in the following link:

[stackoverflow.com/questions/6980906/android-color-picker](Color Picker, 3rd post)

However, to implement this is not is not straight forward to me. I think I am failing at this because of the activity life cycle concepts working with this type of code. I have implemented (borrowed some code) successfully https://forum.processing.org/two/discussion/comment/69600/#Comment_69600 and toggle buttons before by adding them to the current view group during the OnCreate function call in the processing sktch. I have also implemented Toast messages through a Thread call associated to the current activity. For this code from the link I have few challenges:

First the main class, ColorPickerDialog extends from the dialog class. I have a feeling it behaves as toast messages except there is a need for user input before a dismiss() function is called and returns to the previous part of the program. Int he code, it defines the class ColorPickerView that extends from the View class. It is in the constructor of the main class (ColorPickerDialog) where it instantiates the view object and it is there when it gets associated to the ViewGroup. What changes should I implement to be able to re-use this class in processing?

Adding to my current state of confusion is the definition of OnColorChangedListener which is defined inside the main class ColorPickerDialog and the listener implemented in its constructor. However if I want to use it in processing then it needs to be defined in the processing sketch. This brings my last question. In the code from the aforementioned website, they define an OnCreate function call within the class. Should I scrap that method and implement it in processing (or should I override it?)

I have a feeling that this code have to be completely modified to be able to re-use it. An idea would be if I could make ColorPickerDialog extend from both Dialog and View classes but I am not sure if this would make sense. I still not sure how to address the listener class call. I think it could be as simple as what is presented in previous posts but I am not sure.

Thanks for your comments,

Kf


Viewing all articles
Browse latest Browse all 941

Trending Articles