I'm partly new to programming in Android and Java in general, and I can't figure out what causes this error; as I understand it, this should work. In the code shown below (near the end of the first snippet), the line "ColourOutput.do_output((Activity) com.(name-removed).(app-name-removed).ColourActivity);"reports an error "Expression expected"in the text "com.(name-removed).(app-name-removed).ColourActivity"in Android Studio 1.1.0.
(This is inside the class "public class ColourActivity extends Activity".)
private Camera.PreviewCallback preview_callback = new Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
int width = mCamera.getParameters().getPreviewSize().width;
int height = mCamera.getParameters().getPreviewSize().height;
int raw_pixels[];
int pixels[];
raw_pixels = new int[width * height];
pixels = new int[get_sample_width() * get_sample_height()];
convert_yuv(raw_pixels, data, width, height);
crop_pixels(raw_pixels, pixels, width, height, (width - get_sample_width()) / 2, (height - get_sample_height()) / 2, get_sample_width(), get_sample_height());
if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("use_mean", true) == true) {
ColourOutput.add_colour_to_output(
ColourTools.get_mean(
pixels, get_sample_width(), get_sample_height(),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_secondary", true),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_white", true),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_brightness", true),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_secondary", 32),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_dark", 43),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_light", 128),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("quantization_matching_only", true)
),
ColourOutput.ColourType.MEAN);
}
if (PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("use_mode", true) == true) {
ColourOutput.add_colour_to_output(
ColourTools.get_mode(
pixels, get_sample_width(), get_sample_height(),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_secondary", true),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_white", true),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("detect_brightness", true),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_secondary", 32),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_dark", 43),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getInt("quantization_light", 128),
PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("quantization_matching_only", true)
),
ColourOutput.ColourType.MODE);
}
ColourOutput.do_output((Activity) com.(name-removed).(app-name-removed).ColourActivity);
}
};
Here is the definition of "ColourOutput.do_output" :
public class ColourOutput {
private static boolean output_clear = true;
private static String output_buffer = "";
public static enum ColourType {
MEAN,
MODE
}
public static void add_colour_to_output(ColourTools.ColourDescription colour, ColourType type) {
if (output_clear == true) {
output_buffer = colour.Brightness.toString() + " " + colour.Colour.toString();
}
else {
output_buffer = output_buffer + " " + colour.Brightness.toString() + " " + colour.Colour.toString();
}
output_clear = false;
}
public static void do_output(Activity activity) {
((TextView) activity.findViewById(R.id.output_text)).setText(output_buffer);
output_buffer = "";
output_clear = true;
}
}