Monodroid: TeeCharts disappear when I scroll the view - android

I am supposed to add 4 teechart controls at runtime. I am able to bind the values to teechart controls.
The problem is, when I scroll the parent view, all the teecharts disappear. But all other controls are visible (button, textview, etc.).
Note: initially all the controls are visible; they disappear only when I scroll.
void drawRainfallChart()
{
try
{
obj = new csGraphClass();
RainfallGraph[] graphdata = obj.getRainfallData(_cropId.ToString());
if (rainfallChart == null)
rainfallChart = new Steema.TeeChart.TChart(this);
else
{
rainfallChart.RemoveAllViews();
rainfallChart.Dispose();
rainfallChart = new Steema.TeeChart.TChart(this);
}
if (graphdata.Length > 0)
{
rainfallChart.Aspect.View3D = false;
rainfallChart.Chart.Invalidate();
Steema.TeeChart.Styles.Line rline = new Steema.TeeChart.Styles.Line();
Steema.TeeChart.Styles.Line rCrtdayline = new Steema.TeeChart.Styles.Line();
rainfallChart.Series.Add(rline);
rainfallChart.Series.Add(rCrtdayline);
DateTime currentdate = SyncProcess.CalculatedDatetime();
double dc = 0;
foreach (RainfallGraph item in graphdata)
{
dc += Convert.ToDouble(item.yValue);
rline.Add(Convert.ToDateTime(item.xValue), dc);
if (item.xValue == currentdate.ToString("yyyy-MM-dd"))
{
rCrtdayline.Add(Convert.ToDateTime(item.xValue), 0);
rCrtdayline.Add(Convert.ToDateTime(item.xValue), Convert.ToDouble(item.yValue));
}
}
rline.Title = "Rainfall";
rCrtdayline.Title = "Crop Day";
rline.Pointer.Visible = true;
rline.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.Circle;
rline.Chart.Axes.Left.SetMinMax(0, Convert.ToDouble(dc + 5));
var varMinDate = graphdata.Min(s => s.xValue);
var varMaxDate = graphdata.Max(s => s.xValue);
DateTime minDate = Convert.ToDateTime(varMinDate).AddDays(-1);
DateTime maxDate = Convert.ToDateTime(varMaxDate).AddDays(1);
rline.Chart.Axes.Bottom.SetMinMax(minDate, maxDate);
rainfallChart.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneDay);
rainfallChart.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy";
rainfallChart.Footer.Font.Size = 25;
rainfallChart.Legend.Font.Size = 25;
rainfallChart.Header.Font.Size = 25;
rainfallChart.Axes.Bottom.Labels.Font.Size = 18;
rainfallChart.Axes.Left.Labels.Font.Size = 15;
rainfallChart.Legend.Transparent = true;
rainfallChart.Header.Visible = true;
rainfallChart.Axes.Bottom.Grid.Visible = false;
rainfallChart.Header.Text = "Rain fall";
rainfallChart.Legend.Visible = true;
rainfallChart.Axes.Left.Grid.DrawEvery = 1;
rainfallChart.Legend.Alignment = Steema.TeeChart.LegendAlignments.Bottom;
rainfallChart.Panning.Allow = Steema.TeeChart.ScrollModes.None;
rainfallChart.Panning.Allow = Steema.TeeChart.ScrollModes.None;
rainfallChart.Zoom.Style = Steema.TeeChart.ZoomStyles.Classic;
rainfallChart.Zoom.Allow = false;
rainfallChart.Panning.Allow = ScrollModes.None;
rainfallChart.SetPadding(0, 50, 0, 50);
Android.Widget.LinearLayout.LayoutParams layoutParams = new Android.Widget.LinearLayout.LayoutParams(graphheight, graphwidth);
layoutParams.TopMargin = 100;
layoutParams.BottomMargin = 100;
rainfallChart.ScrollBarStyle = ScrollbarStyles.InsideOverlay;
rainfallChart.SetScrollContainer(false);
srcgraph.AddView(rainfallChart, layoutParams);
}
}
catch (Exception ex)
{
ErrorHandling.ErrorEntry(ex.Message.ToString(), "TodayGraphViewController - drawRainfallChart");
}
}

Another user recently reported a similar issue (TM63016590) when Zoom.Style is set to ZoomStyles.Classic. We have a fix suggestion for this, which is available in the current evaluation version available at https://www.steema.com/downloads/net_android. Could you please let us know if it solves the problem at your end?

Related

adapter addAll replaces the items of previous page, android

When the user hit the bottom of my listview, the second page is loaded and displayed. The problem is that, when it happens, the items of the first page are replaced with the ones of the second page. This video show the behaviour: https://www.ubris.design/video.mp4
and this is my code, inside the respomnse callback of my webservice:
try {
JSONObject obj = new JSONObject(result);
JSONObject response = obj.getJSONObject("response");
Integer count = Integer.parseInt(response.getString("count"));
//Toast.makeText(getApplicationContext(),count+"", Toast.LENGTH_LONG).show();
inputItems.clear();
for(int i = 0; i < count; i++){
JSONObject tmp = response.getJSONObject(i+"");
id = tmp.getString("id");
materia = tmp.getString("materia");
adsce = tmp.getString("adsce");
nomeCompleto = tmp.getString("nomeCompleto");
matricola = tmp.getString("matricola");
username = tmp.getString("username");
password = tmp.getString("password");
uni = tmp.getString("uni");
descrizione = tmp.getString("descrizione");
type = tmp.getString("type");
voto = tmp.getString("voto");
votanti = tmp.getString("votanti");
ts = tmp.getString("ts");
//url
siteTitle = tmp.getString("siteTitle");
siteDescription = tmp.getString("siteDescription");
siteImage = tmp.getString("siteImage");
address = tmp.getString("address");
//file
filename = tmp.getString("filename");
filesize = tmp.getString("filesize");
combinedSize = tmp.getString("combinedSize");
//Toast.makeText(getApplicationContext(), filename+address, Toast.LENGTH_LONG).show();
inputItems.add(new DTODocSelected(id, materia, adsce, nomeCompleto, matricola, null, null, uni, descrizione,type, voto, votanti, ts,
siteTitle, siteDescription, siteImage, address,
filename, filesize, combinedSize
));
}
} catch (Exception e){
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
if(inputItems.size() > 0){
if(page == 0){
adapter = new AdapterDocMateriaDocsSelect(getApplicationContext(),
R.id.activity_docs_doc_selected, inputItems);
listView.setAdapter(adapter);
listView.setSmoothScrollbarEnabled(true);
listView.setScrollingCacheEnabled(false);
listView.setDrawingCacheEnabled(false);
listView.destroyDrawingCache();
listView.buildDrawingCache(false);
listView.getDrawingCache(false);
double vv = Integer.valueOf(counterCC);
double pagineMax = Math.ceil( vv / 5);
int pagineMaxInt = (int) pagineMax;
if(page == (pagineMaxInt - 1)){
pagination = false;
Toast.makeText(getApplicationContext(), "pagination false", Toast.LENGTH_SHORT).show();
}
} else {
//Toast.makeText(getApplicationContext(), ""+inputItems.size(), Toast.LENGTH_SHORT).show();
double vv = Integer.valueOf(counterCC);
double pagineMax = Math.ceil( vv / 5);
int pagineMaxInt = (int) pagineMax;
if(page == (pagineMaxInt - 1)){
pagination = false;
Toast.makeText(getApplicationContext(), "pagination false", Toast.LENGTH_SHORT).show();
}
adapter.addAll(inputItems);
//inputItems.clear();
//listView.setSmoothScrollbarEnabled(true);
//listView.smoothScrollToPosition(page * 5);
}
} else {
pagination = false;
//Toast.makeText(getApplicationContext(), "zero", Toast.LENGTH_LONG).show();
}
to solve I just replaced adapter.addAll(inputItems); with adapter.notifyDataSetChanged(); and removed inputItems.clear();

Black Screen with MSAA on Android with Vulkan

I have a problem with MSAA setup on Android. On any desktop machine tested (Intel, NVIDIA) I get a correct resolve framebuffer and renderpass (I currently have an empty renderpass where I only clear the back color) and the screen renders simply grey (desired) but on android the screen is black.
I do not get any validation errors. The code just "works" but it does not seem right to me.
Here is my Renderpass code:
VkSampleCountFlagBits sampleCount = GetMaxUsableSampleCount();
VkAttachmentDescription colorResolveAttachment = {};
colorResolveAttachment.format = mSwapchainImageFormat;
colorResolveAttachment.samples = sampleCount;
colorResolveAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
colorResolveAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorResolveAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
colorResolveAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorResolveAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colorResolveAttachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkAttachmentDescription colorAttachment = {};
colorAttachment.format = mSwapchainImageFormat;
colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
colorAttachment.loadOp = (mSamples != 0) ? VK_ATTACHMENT_LOAD_OP_DONT_CARE : VK_ATTACHMENT_LOAD_OP_CLEAR;
colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
VkAttachmentDescription depthResolveAttachment = {};
depthResolveAttachment.format = mDepthImageFormat;
depthResolveAttachment.samples = sampleCount;
depthResolveAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
depthResolveAttachment.storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthResolveAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
depthResolveAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthResolveAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
depthResolveAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkAttachmentDescription depthAttachment = {};
depthAttachment.format = mDepthImageFormat;
depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
depthAttachment.loadOp = (mSamples != 0) ? VK_ATTACHMENT_LOAD_OP_DONT_CARE : VK_ATTACHMENT_LOAD_OP_CLEAR;
depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
depthAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkAttachmentReference colorAttachmentRef = {};
colorAttachmentRef.attachment = 0;
colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkAttachmentReference depthAttachmentRef = {};
depthAttachmentRef.attachment = (mSamples != 0) ? 2 : 1;
depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
VkAttachmentReference colorAttachmentResolveRef = {};
colorAttachmentResolveRef.attachment = 1;
colorAttachmentResolveRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
VkSubpassDescription subpass = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colorAttachmentRef;
subpass.pDepthStencilAttachment = &depthAttachmentRef;
if(mSamples != 0)
{
subpass.pResolveAttachments = &colorAttachmentResolveRef;
}
std::vector<VkSubpassDependency> dependencies;
if(mSamples != 0)
{
std::array<VkSubpassDependency, 2> dependency;
dependency[0].srcSubpass = VK_SUBPASS_EXTERNAL;
dependency[0].dstSubpass = 0;
dependency[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
dependency[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dependency[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
dependency[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
dependency[1].srcSubpass = 0;
dependency[1].dstSubpass = VK_SUBPASS_EXTERNAL;
dependency[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
dependency[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
dependency[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
dependency[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT;
dependencies.push_back(dependency[0]);
dependencies.push_back(dependency[1]);
}
else
{
VkSubpassDependency dependency = {};
dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
dependency.dstSubpass = 0;
dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.srcAccessMask = 0;
dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
dependencies.push_back(dependency);
}
std::vector<VkAttachmentDescription> attachments;
if(mSamples != 0)
{
attachments.push_back(colorResolveAttachment);
attachments.push_back(colorAttachment);
attachments.push_back(depthResolveAttachment);
attachments.push_back(depthAttachment);
}
else
{
attachments.push_back(colorAttachment);
attachments.push_back(depthAttachment);
}
VkRenderPassCreateInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
renderPassInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
renderPassInfo.pAttachments = attachments.data();
renderPassInfo.subpassCount = 1;
renderPassInfo.pSubpasses = &subpass;
renderPassInfo.dependencyCount = static_cast<uint32_t>(dependencies.size());
renderPassInfo.pDependencies = dependencies.data();
if(vkCreateRenderPass(mDevice, &renderPassInfo, nullptr, &mRenderPass) != VK_SUCCESS)
{
Console::FatalError("Failed to create render pass!");
return false;
}
return true;
Here is my Freambuffer code:
if(!CreateMultiSampleTargets())
return false;
mSwapchainFramebuffers.resize(mSwapchainImageViews.size());
for(size_t i = 0u; i < mSwapchainImageViews.size(); i++)
{
std::vector<VkImageView> attachments;
if(mSamples != 0)
{
attachments.push_back(mMultiSampleColorImageView);
attachments.push_back(mSwapchainImageViews[i]);
attachments.push_back(mMultiSampleDepthImageView);
attachments.push_back(mDepthImageView);
}
else
{
attachments.push_back(mSwapchainImageViews[i]);
attachments.push_back(mDepthImageView);
}
VkFramebufferCreateInfo framebufferInfo = {};
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
framebufferInfo.renderPass = mRenderPass;
framebufferInfo.attachmentCount = static_cast<uint32_t>(attachments.size());
framebufferInfo.pAttachments = attachments.data();
framebufferInfo.width = mSwapchainExtent.width;
framebufferInfo.height = mSwapchainExtent.height;
framebufferInfo.layers = 1;
if(vkCreateFramebuffer(mDevice, &framebufferInfo, nullptr, &mSwapchainFramebuffers[i]) != VK_SUCCESS)
{
Console::FatalError("Failed to create framebuffer!");
return false;
}
}
I should mention that my code is heavily based on this: https://github.com/SaschaWillems/Vulkan/blob/master/multisampling/multisampling.cpp
The solution was to upgrade my Oneplus 3 to android 8 to get a newer driver version where this issue does not occur. I guess this was a driver bug.

500 internal server error when writing file to the server

I'm developing an android app with Xamarin that uploads file to the server. My server is asp.net based and is hosted by azure. Xamarin throws this error when the code tries to write the file to the server directory. The code I'm using to post the file to the server is as follows:
public async Task<HttpResponseMessage> UploadFile(byte[] file)
{
videoThumbName = Guid.NewGuid().ToString();
var progress = new System.Net.Http.Handlers.ProgressMessageHandler();
progress.HttpSendProgress += progress_HttpSendProgress;
using (var client = HttpClientFactory.Create(progress))
{
client.BaseAddress = new Uri(GlobalVariables.host);
// Set the Accept header for BSON.
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/bson"));
var request = new uploadFileModel { data = file, dateCreated = DateTime.Now, fileName = fileName, username = loggedUser, VideoThumbName = videoThumbName};
// POST using the BSON formatter.
MediaTypeFormatter bsonFormatter = new BsonMediaTypeFormatter();
var m = client.MaxResponseContentBufferSize;
var result = await client.PostAsync("api/media/upload", request, bsonFormatter);
return result.EnsureSuccessStatusCode();
}
}
I've tried using a try catch block and the weird thing is that the exception is caught even after the file has been written to the path and I get the 500 internal server error. So far every file I tried to upload was save to the path but I can't figure out why is error occurring.
My server side code looks like the following:
[HttpPost]
[Route("upload")]
public async Task<HttpResponseMessage> Upload(uploadFileModel model)
{
var result = new HttpResponseMessage(HttpStatusCode.OK);
if (ModelState.IsValid)
{
string thumbname = "";
string resizedthumbname = Guid.NewGuid() + "_yt.jpg";
string FfmpegPath = Encoding_Settings.FFMPEGPATH;
string tempFilePath = Path.Combine(HttpContext.Current.Server.MapPath("~/tempuploads"), model.fileName);
string pathToFiles = HttpContext.Current.Server.MapPath("~/tempuploads");
string pathToThumbs = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/thumbs");
string finalPath = HttpContext.Current.Server.MapPath("~/contents/member/" + model.username + "/flv");
string resizedthumb = Path.Combine(pathToThumbs, resizedthumbname);
var outputPathVid = new MediaFile { Filename = Path.Combine(finalPath, model.fileName) };
var inputPathVid = new MediaFile { Filename = Path.Combine(pathToFiles, model.fileName) };
int maxWidth = 380;
int maxHeight = 360;
var namewithoutext = Path.GetFileNameWithoutExtension(Path.Combine(pathToFiles, model.fileName));
thumbname = model.VideoThumbName;
string oldthumbpath = Path.Combine(pathToThumbs, thumbname);
var fileName = model.fileName;
try
{
File.WriteAllBytes(tempFilePath, model.data);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
if (model.fileName.Contains("audio"))
{
File.WriteAllBytes(Path.Combine(finalPath, model.fileName), model.data);
string audio_thumb = "mic_thumb.jpg";
string destination = Path.Combine(pathToThumbs, audio_thumb);
string source = Path.Combine(pathToFiles, audio_thumb);
if (!System.IO.File.Exists(destination))
{
System.IO.File.Copy(source, destination, true);
}
Video_Struct vd = new Video_Struct();
vd.CategoryID = 0; // store categoryname or term instead of category id
vd.Categories = "";
vd.UserName = model.username;
vd.Title = "";
vd.Description = "";
vd.Tags = "";
vd.OriginalVideoFileName = model.fileName;
vd.VideoFileName = model.fileName;
vd.ThumbFileName = "mic_thumb.jpg";
vd.isPrivate = 0;
vd.AuthKey = "";
vd.isEnabled = 1;
vd.Response_VideoID = 0; // video responses
vd.isResponse = 0;
vd.isPublished = 1;
vd.isReviewed = 1;
vd.Thumb_Url = "none";
//vd.FLV_Url = flv_url;
vd.Embed_Script = "";
vd.isExternal = 0; // website own video, 1: embed video
vd.Type = 0;
vd.YoutubeID = "";
vd.isTagsreViewed = 1;
vd.Mode = 0; // filter videos based on website sections
long videoid = VideoBLL.Process_Info(vd, false);
}
The exception doesn't reveal much for me to understand the issue. Strangely I don't get any errors when I'm sending request to the local server. Any idea what might be wrong here?
Edit:
The exception no longer occurring when I get the internal server error at this line of my code using (var engine = new Engine()) This is a library I'm trying to use to encode a media file. If everything works on the local server then why doesn't it on the live server :/
using (var engine = new Engine())
{
engine.GetMetadata(inputPathVid);
// Saves the frame located on the 15th second of the video.
var outputPathThumb = new MediaFile { Filename = Path.Combine(pathToThumbs, thumbname+".jpg") };
var options = new ConversionOptions { Seek = TimeSpan.FromSeconds(0), CustomHeight = 360, CustomWidth = 380 };
engine.GetThumbnail(inputPathVid, outputPathThumb, options);
}
Image image = Image.FromFile(Path.Combine(pathToThumbs, thumbname+".jpg"));
//var ratioX = (double)maxWidth / image.Width;
//var ratioY = (double)maxHeight / image.Height;
//var ratio = Math.Min(ratioX, ratioY);
var newWidth = (int)(maxWidth);
var newHeight = (int)(maxHeight);
var newImage = new Bitmap(newWidth, newHeight);
Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, newHeight);
Bitmap bmp = new Bitmap(newImage);
bmp.Save(Path.Combine(pathToThumbs, thumbname+"_resized.jpg"));
//File.Delete(Path.Combine(pathToThumbs, thumbname));
using (var engine = new Engine())
{
var conversionOptions = new ConversionOptions
{
VideoSize = VideoSize.Hd720,
AudioSampleRate = AudioSampleRate.Hz44100,
VideoAspectRatio = VideoAspectRatio.Default
};
engine.GetMetadata(inputPathVid);
engine.Convert(inputPathVid, outputPathVid, conversionOptions);
}
File.Delete(tempFilePath);
Video_Struct vd = new Video_Struct();
vd.CategoryID = 0; // store categoryname or term instead of category id
vd.Categories = "";
vd.UserName = model.username;
vd.Title = "";
vd.Description = "";
vd.Tags = "";
vd.Duration = inputPathVid.Metadata.Duration.ToString();
vd.Duration_Sec = Convert.ToInt32(inputPathVid.Metadata.Duration.Seconds.ToString());
vd.OriginalVideoFileName = model.fileName;
vd.VideoFileName = model.fileName;
vd.ThumbFileName = thumbname+"_resized.jpg";
vd.isPrivate = 0;
vd.AuthKey = "";
vd.isEnabled = 1;
vd.Response_VideoID = 0; // video responses
vd.isResponse = 0;
vd.isPublished = 1;
vd.isReviewed = 1;
vd.Thumb_Url = "none";
//vd.FLV_Url = flv_url;
vd.Embed_Script = "";
vd.isExternal = 0; // website own video, 1: embed video
vd.Type = 0;
vd.YoutubeID = "";
vd.isTagsreViewed = 1;
vd.Mode = 0; // filter videos based on website sections
//vd.ContentLength = f_contentlength;
vd.GalleryID = 0;
long videoid = VideoBLL.Process_Info(vd, false);
}`enter code here`

Haxe, OpenFL android debug giving error in for cpp

I'm developing an app in FlashDevelop, using Haxe and OpenFl
When I test my app in flash target, it works fine. But when I compile for android, it comes up with this error during the compilation:
./src/ReaderView2.cpp: In member function 'virtual Void ReaderView2_obj::setZoom()':
./src/ReaderView2.cpp:653: error: base operand of '->' has non-pointer type 'String'
Build halted with errors (haxelib.exe).
...Which is obviously something to do with cpp, which I'm not really an expert.
Does any body know what the error means?
Here's the setZooom function: (the whole file is quite large)
public function setZoom()
{
hideOptions();
while (numChildren > 0)
{
Main.remove(getChildAt(0));
}
if (image != null) if (image.parent != null) image.parent.removeChild(image);
images = new Array();
field = new TextField();
var fieldFont = Assets.getFont("fonts/Kreon-Regular.ttf");
var format:TextFormat = new TextFormat(fieldFont.fontName, currentZoom, 0x4F4F4F);
format.align = TextFormatAlign.LEFT;
field.defaultTextFormat = format;
field.embedFonts = true;
field.text = fullText;
field.selectable = false;
field.wordWrap = true;
field.border = false;
field.autoSize = TextFieldAutoSize.LEFT;
field.width = displayWidth;
//field.x = 0;
//split string into words
var allParas:Array<String> = fullText.split("\r\n");
var words:Array<String>;
var fields:Array<TextField> = new Array();
var tempField:TextField = null;
var contentHeight:Float = displayHeight;
var wordI:Int;
var paraI:Int = 0;
var tempArr2:Array<String>;
while (paraI < allParas.length)
{
if (false) //check img tag
{
}
else //if para is words
{
wordI = 0;
words = allParas[paraI].split(" ");
while (wordI < words.length)
{
if (tempField == null || tempField.textHeight > contentHeight)
{
if (tempField != null) {
wordI--;
tempArr2 = tempField.text.toString().split(" ");
for (i in 0... tempArr2.length)
{
tempArr2.remove("");
}
tempArr2.pop();
tempField.text = tempArr2.join(" ");
}
tempField = new TextField();
tempField.defaultTextFormat = field.getTextFormat();
tempField.embedFonts = true;
tempField.text = "";
tempField.border = false;
tempField.selectable = false;
tempField.wordWrap = true;
tempField.autoSize = TextFieldAutoSize.LEFT;
tempField.width = displayWidth-2;
tempField.x = 0;
fields.push(tempField);
}
else
{
tempField.appendText(words[wordI] + (wordI == words.length - 1? "\n": " "));
wordI++;
}
}
}
paraI++;
}
var bd:BitmapData;
for (i in 0... fields.length)
{
bd = new BitmapData(Std.int(fields[i].width), Std.int(fields[i].height));
bd.draw(fields[i]);
images.push(new Bitmap(bd, PixelSnapping.AUTO, true));
}
//addChild(fields[0]);
images[0].x = 10;
addChild(images[0]);
currentPageInstance = images[0];
currentPage = 0;
drawScrollBar();
if (optionsBtn!=null)addChild(optionsBtn);
}
So apparently using the toString() funcion gives problems for a cpp target.

Android: GraphView How do I implement time in the X axis?

I'm finding it a bit difficult to figure out how to implement time in the X Axis of a graph in Android?
This is my code:
for (int i = 0; i < listSize; i++)
{
String[] onlyReading = mData.get(i).getReading().split(" ");
readingList[i] = Double.parseDouble(onlyReading[0]);
String date = mData.get(i).getUnFormatedDate();
String[] temp = date.split(" ");
String[] dateTemp = null;
String[] timeTemp = null;
if(temp.length > 0)
{
dateTemp = temp[0].trim().split("-");
timeTemp = temp[1].trim().split(":");
Date dateObj = new Date();
String year = "0";
if(dateTemp != null)
{
dateObj.setDate(Integer.parseInt(dateTemp[0]));
dateObj.setMonth(Integer.parseInt(dateTemp[1]) - 1);
year = dateTemp[2].trim();
if(dateTemp[2].trim().length() == 4)
{
year = dateTemp[2].substring(2, 4);
}
dateObj.setYear(Integer.parseInt(year)+100);
}
if(timeTemp != null)
{
calendar = new GregorianCalendar(Integer.parseInt(year) + 2000, Integer.parseInt(dateTemp[1]) - 1, Integer.parseInt(dateTemp[0]), Integer.parseInt(timeTemp[0]), Integer.parseInt(timeTemp[1]));
}
dateObj = new Date(calendar.getTimeInMillis());
dateList[i] = dateObj;
}
}
if(dateList.length > 0)
{
//dates.clear();
//values.clear();
//readingData.clear();
//readingDate.clear();
GraphViewData[] data = new GraphViewData[dateList.length];
LineGraphView graphView = new LineGraphView(
getActivity() // context
, "" // heading
);
for (int i = 0; i < listSize; i++)
{
data[i] = new GraphViewData(Double.valueOf(i), readingList[i]);
}
GraphViewSeries exampleSeries = new GraphViewSeries(data);
graphView.addSeries(exampleSeries);
graphView.setDrawBackground(false);
((LineGraphView) graphView).setDrawDataPoints(true);
graphView.getGraphViewStyle().setGridColor(0);
graphView.getGraphViewStyle().setHorizontalLabelsColor(Color.WHITE);
graphView.getGraphViewStyle().setVerticalLabelsColor(Color.WHITE);
graphView.getGraphViewStyle().setNumHorizontalLabels(5);
graphView.getGraphViewStyle().setNumVerticalLabels(5);
graphView.setManualYAxisBounds(400, 0);
mGraphParent.addView(graphView);
}
}
Even though I add the Y axis values, I'm not able to figure out how to add time values to the X-axis?
I know it is an old question, but I solved by using DefaultLabelFormatter().
graphView.getGridLabelRenderer().setLabelFormatter(new DefaultLabelFormatter() {
#Override
public String formatLabel(double value, boolean isValueX) {
if (isValueX) {
Format formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return formatter.format(value);
}
return super.formatLabel(value, isValueX);
}
});
Based on the following video:
https://www.youtube.com/watch?v=xt8gx7Z7yJU
the trick is to just convert the time to seconds or milliseconds (unix time) and you it as X-value.
There's an example on the GraphView-Demos project. Take a look at:
https://github.com/jjoe64/GraphView-Demos/blob/master/src/com/jjoe64/graphviewdemos/CustomLabelFormatterActivity.java#L68
I had the same issue. The easiest method was to convert Time into milliseconds. Using a Gregorian Calendar might be more helpful as the methods in Date are deprecated.
Calendar cal=new GregorianCalendar(2014,6,12,9,30,0);
data[i]=new GraphViewData(cal.getTimeInMillis,VALUE);
Then set the CustomLabelFormatter.
graphView.setCustomLabelFormatter(new CustomLabelFormatter() {
#Override
public String formatLabel(double value, boolean isValueX) {
// TODO Auto-generated method stub
if (isValueX) {
Date d = new Date((long) (value));
return (dateFormat.format(d));
}
return "" + (int) value;
}
});
Time/Date appears in the format specified in dateFormat.

Categories

Resources