Problem with Dynamic Pivot - Windows Phone 7 Software Development

Hello everyone,
I have a problem with Dynamic Pivot. I create Dynamic Pivot and binding data to it, but Pivot not display content.I tried using MVVM pattern to create Dynamic Pivot and it work well. But I still not know why is it worked (with MVVM).
But i don't want use MVVM pattern in this case. Please tell me know why it not work and how to fix it.
Please see below or download project demo (file attached) to more know . Thanks
XAML
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivot Control-->
<controlsivot x:Name="PivotPlatform" Margin="0,0,8,77" Title="BindingDynamicPivotDemo" ItemsSource="{Binding PivotItems}" >
<controlsivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</controlsivot.HeaderTemplate>
<controlsivot.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding ImagePath}" />
<StackPanel>
<TextBlock Text="{Binding Address}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</controlsivot.ItemTemplate>
</controlsivot>
</Grid>
Code Behind:
public ObservableCollection<Food> PivotItems { get; set; }
public MainPage()
{
InitializeComponent();
// Set the data context of the listbox control to the sample data
//DataContext = App.ViewModel;
PivotItems = new ObservableCollection<Food>();
LoadData();
}
public void LoadData()
{
XDocument loadedData = XDocument.Load("food.xml");
List<Food> data = (from query in loadedData.Descendants("food")
select new Food()
{
Id = (int)query.Element("id"),
Name = (string)query.Element("name"),
Address = (string)query.Element("address"),
ImagePath = (string)query.Element("imagepath"),
Thumbnail = (string)query.Element("thumbnail")
}).ToList();
for (int i = 0; i < data.Count; i++)
{
Food food = (Food)data;
Food header = new Food { Name = food.Name, Address = food.Address, ImagePath = food.ImagePath };
PivotItems.Add(header);
}
}

If you use MVVM the DataContext is set to the MainViewModelSataSource (e.g.).
You have to set the DataContext to your MainPage code.
Code:
<phone:PhoneApplicationPage
[U]x:Name="mainPage"[/U]
x:Class="BindingDynamicPivotDemo.MainPage"
and
Code:
<controls:Pivot x:Name="PivotPlatform" Margin="0,0,8,77" Title="BindingDynamicPivotDemo" ItemsSource="{Binding PivotItems}" [U]DataContext="{Binding ElementName=mainPage}[/U]">
should work

By the way, this probably should go in the Software Development sub-forum. It's dev-related, but doesn't appear to be hacking-related and is more just a general app development question.

Moved to Software Development so you get a few more hits

If you use Caliburn Micro doing this is really simple.
http://caliburnmicro.codeplex.com/S...aliburn.Micro.HelloWP71/PivotPageViewModel.cs

Related

Javascript coder wanted for help in the kitchen...

I (or rather, all of us...) need some code, and I've never really done any Javascript.
Could someone please code:
- Enable all controls on form 0 of a document.
- Walk through all the controls in order. For each control:
- Make a temporary string that holds the name of the control
- add a slash and the value of the control if it is a checkbox
- Walk through all the controls again
- Disable any controls:
- whose name is longer, but starts with the temp string above
- which are radiobuttons whose name is the temp-string
- done
This would disable any controls that do not apply when the user deselects a higher-level checkbox or radio-button, which would look much cleaner and cooler. I would have to spend most of today on this learning enough Javascript and fixing stupid beginner-bugs, and I would be disapointed if we don't have at least a few people here who can code this in 10 minutes.
Code can be tested by copying the form from the kitchen locally and creating a function to replace the submit placed at every checkbox or radiobutton control.
ok, consider this a beta
i did not follow your design in whole
but still i hope the functionality is the same
email me to [email protected] for any needed changes
my local time is 2:31 after midnight
uh uaah, good night
Code:
<html>
<head>
<script>
function setupDisable() {
var myForm = document.getElementById('myForm');
// enable all of them
for(var i=0; i<myForm.elements.length; i++) {
myForm.elements[i].disabled = false;
}
// foreach assign a tmpName
for(var i=0; i<myForm.elements.length; i++) {
var tmpName = myForm.elements[i].name;
if (myForm.elements[i].type == 'checkbox') {
// IMHO this is not needed and will break the functionality
// and this fact renders this whole cycle useless :)
// you can just use the name
// property in fuiction doDisable...
//tmpName += '/' + myForm.elements[i].value;
}
myForm.elements[i].tmpName = tmpName;
}
}
function doDisable(root) {
// disable all children
var myName = root.tmpName;
var myForm = document.getElementById('myForm');
if (!root.checked) {
alert('went off');
for(var i=0; i<myForm.elements.length; i++) {
var actName = myForm.elements[i].name;
if (actName.indexOf(myName) == 0 && actName != myName) {
myForm.elements[i].disabled = true;
}
}
} else {
alert('went on');
for(var i=0; i<myForm.elements.length; i++) {
var actName = myForm.elements[i].name;
if (actName.indexOf(myName) == 0 && actName != myName) {
myForm.elements[i].disabled = false;
}
}
}
}
</script>
</head>
<body onload="setupDisable()">
<form id="myForm">
<INPUT TYPE="checkbox" name="in1" onclick="doDisable(this)">in1
<INPUT TYPE="checkbox" name="in2" onclick="doDisable(this)">in2
<INPUT TYPE="radio" name="in2/1" value="1" onclick="doDisable(this)">in2/1
<INPUT TYPE="radio" name="in2/1" value="2" onclick="doDisable(this)">in2/1
<INPUT TYPE="radio" name="in2/1" value="3" onclick="doDisable(this)">in2/1
</form>
</body>
</html>

DirectShow: Video-Preview and taking photo (with working code)

Questions
As mentioned in the text below the TakePicture() method is not working properly on the HTC HD 2 device. It would be nice if someone could look at the code below and tell me if it is right or wrong what I'm doing.
Introduction
I recently asked a question on another forum about displaying a video preview and taking camera image with DirectShow. The tricky thing about the topic is, that it's very hard to find good examples and the documentation and the framework itself is very hard to understand for someone who is new to windows programming and C++ in general.
Nevertheless I managed to create a class that implements most of this features and probably works with most mobile devices. Probably because as far as I know the DirectShow implementation depends a lot on the device itself. I could only test it with the HTC HD and HTC HD2, which are known as quite incompatible.
HTC HD
- Working: Video preview, writing photo to file
- Not working: Set video resolution (CRASH), set photo resolution (LOW quality)
HTC HD 2
- Working: Set video resolution, set photo resolution
- Problematic: Video Preview rotated
- Not working: Writing photo to file
To make it easier for others by providing a working example, I decided to share everything I have got so far below. I removed all of the error handling for the sake of simplicity. As far as documentation goes, I can recommend you to read the MSDN documentation about the topic. After that the code below is pretty straight forward.
Code:
void Camera::Init()
{
CreateComObjects();
_captureGraphBuilder->SetFiltergraph(_filterGraph);
InitializeVideoFilter();
InitializeStillImageFilter();
}
Dipslay a video preview (working with any tested handheld):
Code:
void Camera::DisplayVideoPreview(HWND windowHandle)
{
IVideoWindow *_vidWin;
_filterGraph->QueryInterface(IID_IMediaControl,(void **) &_mediaControl);
_filterGraph->QueryInterface(IID_IVideoWindow, (void **) &_vidWin);
_videoCaptureFilter->QueryInterface(IID_IAMVideoControl,
(void**) &_videoControl);
_captureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, _videoCaptureFilter, NULL, NULL);
CRect rect;
long width, height;
GetClientRect(windowHandle, &rect);
_vidWin->put_Owner((OAHWND)windowHandle);
_vidWin->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS);
_vidWin->get_Width(&width);
_vidWin->get_Height(&height);
height = rect.Height();
_vidWin->put_Height(height);
_vidWin->put_Width(rect.Width());
_vidWin->SetWindowPosition(0,0, rect.Width(), height);
_mediaControl->Run();
}
HTC HD2: If set SetPhotoResolution() is called FindPin will return E_FAIL. If not, it will create a file full of null bytes. HTC HD: Works
void Camera::TakePicture(WCHAR *fileName)
{
CComPtr<IFileSinkFilter> fileSink;
CComPtr<IPin> stillPin;
CComPtr<IUnknown> unknownCaptureFilter;
CComPtr<IAMVideoControl> videoControl;
_imageSinkFilter.QueryInterface(&fileSink);
fileSink->SetFileName(fileName, NULL);
_videoCaptureFilter.QueryInterface(&unknownCaptureFilter);
_captureGraphBuilder->FindPin(unknownCaptureFilter, PINDIR_OUTPUT,
&PIN_CATEGORY_STILL, &MEDIATYPE_Video, FALSE, 0, &stillPin);
_videoCaptureFilter.QueryInterface(&videoControl);
videoControl->SetMode(stillPin, VideoControlFlag_Trigger);
}
Set resolution: Works great on HTC HD2. HTC HD won't allow SetVideoResolution() and only offers one low resolution photo resolution:
Code:
void Camera::SetVideoResolution(int width, int height)
{
SetResolution(true, width, height);
}
void Camera::SetPhotoResolution(int width, int height)
{
SetResolution(false, width, height);
}
void Camera::SetResolution(bool video, int width, int height)
{
IAMStreamConfig *config;
config = NULL;
if (video)
{
_captureGraphBuilder->FindInterface(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, _videoCaptureFilter, IID_IAMStreamConfig,
(void**) &config);
}
else
{
_captureGraphBuilder->FindInterface(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, _videoCaptureFilter, IID_IAMStreamConfig,
(void**) &config);
}
int resolutions, size;
VIDEO_STREAM_CONFIG_CAPS caps;
config->GetNumberOfCapabilities(&resolutions, &size);
for (int i = 0; i < resolutions; i++)
{
AM_MEDIA_TYPE *mediaType;
if (config->GetStreamCaps(i, &mediaType,
reinterpret_cast<BYTE*>(&caps)) == S_OK )
{
int maxWidth = caps.MaxOutputSize.cx;
int maxHeigth = caps.MaxOutputSize.cy;
if(maxWidth == width && maxHeigth == height)
{
VIDEOINFOHEADER *info =
reinterpret_cast<VIDEOINFOHEADER*>(mediaType->pbFormat);
info->bmiHeader.biWidth = maxWidth;
info->bmiHeader.biHeight = maxHeigth;
info->bmiHeader.biSizeImage = DIBSIZE(info->bmiHeader);
config->SetFormat(mediaType);
DeleteMediaType(mediaType);
break;
}
DeleteMediaType(mediaType);
}
}
}
Other methods used to build the filter graph and create the COM objects:
v
Code:
oid Camera::CreateComObjects()
{
CoInitialize(NULL);
CoCreateInstance(CLSID_CaptureGraphBuilder, NULL, CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2, (void **) &_captureGraphBuilder);
CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **) &_filterGraph);
CoCreateInstance(CLSID_VideoCapture, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**) &_videoCaptureFilter);
CoCreateInstance(CLSID_IMGSinkFilter, NULL, CLSCTX_INPROC,
IID_IBaseFilter, (void**) &_imageSinkFilter);
}
void Camera::InitializeVideoFilter()
{
_videoCaptureFilter->QueryInterface(&_propertyBag);
wchar_t deviceName[MAX_PATH] = L"\0";
GetDeviceName(deviceName);
CComVariant comName = deviceName;
CPropertyBag propertyBag;
propertyBag.Write(L"VCapName", &comName);
_propertyBag->Load(&propertyBag, NULL);
_filterGraph->AddFilter(_videoCaptureFilter,
L"Video Capture Filter Source");
}
void Camera::InitializeStillImageFilter()
{
_filterGraph->AddFilter(_imageSinkFilter, L"Still image filter");
_captureGraphBuilder->RenderStream(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, _videoCaptureFilter, NULL, _imageSinkFilter);
}
void Camera::GetDeviceName(WCHAR *deviceName)
{
HRESULT hr = S_OK;
HANDLE handle = NULL;
DEVMGR_DEVICE_INFORMATION di;
GUID guidCamera = { 0xCB998A05, 0x122C, 0x4166, 0x84, 0x6A, 0x93, 0x3E,
0x4D, 0x7E, 0x3C, 0x86 };
di.dwSize = sizeof(di);
handle = FindFirstDevice(DeviceSearchByGuid, &guidCamera, &di);
StringCchCopy(deviceName, MAX_PATH, di.szLegacyName);
}
Full header file:
Code:
#ifndef __CAMERA_H__
#define __CAMERA_H__
class Camera
{
public:
void Init();
void DisplayVideoPreview(HWND windowHandle);
void TakePicture(WCHAR *fileName);
void SetVideoResolution(int width, int height);
void SetPhotoResolution(int width, int height);
private:
CComPtr<ICaptureGraphBuilder2> _captureGraphBuilder;
CComPtr<IGraphBuilder> _filterGraph;
CComPtr<IBaseFilter> _videoCaptureFilter;
CComPtr<IPersistPropertyBag> _propertyBag;
CComPtr<IMediaControl> _mediaControl;
CComPtr<IAMVideoControl> _videoControl;
CComPtr<IBaseFilter> _imageSinkFilter;
void GetDeviceName(WCHAR *deviceName);
void InitializeVideoFilter();
void InitializeStillImageFilter();
void CreateComObjects();
void SetResolution(bool video, int width, int height);
};
#endif
Hey, in the FindInterface for the you're not checking the return code, which has to be S_OK; if not, the config is NULL and using config-> will cause your crash. If FindInterface for PIN_CATEGORY_PREVIEW is failing, try FindInterface for PIN_CATEGORY_CAPTURE.

XNA -Please Help - Collide with angle object

I'm developing a mirror for lazer beam(Ball sprite). There I'm trying to redirect the laze beam according to the ration degree of the mirror(Rectangle). How can I collide the ball to the correct angle if the colliding object is with some angle(45 deg) rather than colliding back.
Here is my complete code
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace collision
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D ballTexture;
Rectangle ballBounds;
Vector2 ballPosition;
Vector2 ballVelocity;
float ballSpeed = 30f;
Texture2D blockTexture;
Rectangle blockBounds;
Vector2 blockPosition;
private Vector2 origin;
KeyboardState keyboardState;
//Font
SpriteFont Font1;
Vector2 FontPos;
private String displayText;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
ballPosition = new Vector2(this.GraphicsDevice.Viewport.Width / 2,
this.GraphicsDevice.Viewport.Height * 0.25f);
blockPosition = new Vector2(this.GraphicsDevice.Viewport.Width / 2,
this.GraphicsDevice.Viewport.Height /2);
ballVelocity = new Vector2(0, 1);
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
ballTexture = Content.Load<Texture2D>("ball");
blockTexture = Content.Load<Texture2D>("mirror");
//create rectangles based off the size of the textures
ballBounds = new Rectangle((int)(ballPosition.X - ballTexture.Width / 2),
(int)(ballPosition.Y - ballTexture.Height / 2), ballTexture.Width, ballTexture.Height);
blockBounds = new Rectangle((int)(blockPosition.X - blockTexture.Width / 2),
(int)(blockPosition.Y - blockTexture.Height / 2), blockTexture.Width, blockTexture.Height);
origin.X = blockTexture.Width / 2;
origin.Y = blockTexture.Height / 2;
// TODO: use this.Content to load your game content here
Font1 = Content.Load<SpriteFont>("SpriteFont1");
FontPos = new Vector2(graphics.GraphicsDevice.Viewport.Width - 100, 20);
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// all content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
///
private float RotationAngle;
float circle = MathHelper.Pi * 2;
float angle;
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
//check for collision between the ball and the block, or if the ball is outside the bounds of the screen
if (ballBounds.Intersects(blockBounds) || !GraphicsDevice.Viewport.Bounds.Contains(ballBounds))
{
//we have a simple collision!
//if it has hit, swap the direction of the ball, and update it's position
ballVelocity = -ballVelocity;
ballPosition += ballVelocity * ballSpeed;
}
else
{
//move the ball a bit
ballPosition += ballVelocity * ballSpeed;
}
//update bounding boxes
ballBounds.X = (int)ballPosition.X;
ballBounds.Y = (int)ballPosition.Y;
blockBounds.X = (int)blockPosition.X;
blockBounds.Y = (int)blockPosition.Y;
keyboardState = Keyboard.GetState();
float val = 1.568017f/90;
if (keyboardState.IsKeyDown(Keys.Space))
RotationAngle = RotationAngle + (float)Math.PI;
if (keyboardState.IsKeyDown(Keys.Left))
RotationAngle = RotationAngle - val;
angle = (float)Math.PI / 4.0f; // 90 degrees
RotationAngle = angle;
// RotationAngle = RotationAngle % circle;
displayText = RotationAngle.ToString();
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
spriteBatch.Begin();
// Find the center of the string
Vector2 FontOrigin = Font1.MeasureString(displayText) / 2;
spriteBatch.DrawString(Font1, displayText, FontPos, Color.White, 0, FontOrigin, 1.0f, SpriteEffects.None, 0.5f);
spriteBatch.Draw(ballTexture, ballPosition, Color.White);
spriteBatch.Draw(blockTexture, blockPosition,null, Color.White, RotationAngle,origin, 1.0f, SpriteEffects.None, 0f);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
Do you have a github repo? I would like to help out but your wording is slightly confusing. You may have to update your collision to reflect changes in the X and Y axes seperately. I can try to replicate this and PM you my solution

Hooking a protected List in an Inner Class with an odd set of Parameters

So, I'm getting fairly good at hooking and modifying classes, but this one is so unique, I'm not quite sure how to approach hooking it to do what I want. Code for the method/class I want to attack:
Code:
private class CreateLaunchPointListTask
extends AsyncTask<Void, Void, List<LaunchPoint>>
{
private CreateLaunchPointListTask() {}
protected List<LaunchPoint> doInBackground(Void... paramVarArgs)
{
paramVarArgs = mContext.getString(2131558445);
Object localObject = new Intent("android.intent.action.MAIN");
((Intent)localObject).addCategory(paramVarArgs);
paramVarArgs = new LinkedList();
PackageManager localPackageManager = mContext.getPackageManager();
localObject = localPackageManager.queryIntentActivities((Intent)localObject, 129);
int j = ((List)localObject).size();
int i = 0;
while (i < j)
{
ResolveInfo localResolveInfo = (ResolveInfo)((List)localObject).get(i);
if (activityInfo != null) {
paramVarArgs.add(new LaunchPoint(mContext, localPackageManager, localResolveInfo));
}
i += 1;
}
return paramVarArgs;
}
public void onPostExecute(List<LaunchPoint> arg1)
{
synchronized (mLock)
{
mAllLaunchPoints.clear();
mAllLaunchPoints.addAll(???);
synchronized (mCachedActions)
{
LaunchPointListGenerator.access$502(LaunchPointListGenerator.this, true);
if (!mCachedActions.isEmpty()) {
((LaunchPointListGenerator.CachedAction)mCachedActions.remove()).apply();
}
}
}
LaunchPointListGenerator.access$602(LaunchPointListGenerator.this, true);
Iterator localIterator = mListeners.iterator();
while (localIterator.hasNext()) {
((LaunchPointListGenerator.Listener)localIterator.next()).onLaunchPointListGeneratorReady();
}
}
}
So, while this is a big chunk of code, everything I want to do is really in the first few lines:
Code:
paramVarArgs = mContext.getString(2131558445);
Object localObject = new Intent("android.intent.action.MAIN");
((Intent)localObject).addCategory(paramVarArgs);
So, string 2131558445 is a specific intent. What I would like to do is add *another* category after 2131558445 is added to localObject.
That would be the simplest implementation.
A more advanced implementation would be to actually and return a second LinkedList, paramVarArgs2, that only matches up to the second intent category that we're inserting.
Any help would be greatly appreciated.

GWD sources

It seems the ALARM and NOTIFICATION sources aren't shown in GWD. But they may be useable by modding the xml. Likely as sources for a hand, text, digital clock etc.
Code:
package com.samsung.gwd.source;
import java.util.HashMap;
public class Source
{
public static final String SOURCE_CALORIE_CAL = "cal";
public static final String SOURCE_CALORIE_KCAL = "kcal";
public static final String SOURCE_CALORIE_UNIT_CAL = "(cal)";
public static final String SOURCE_CALORIE_UNIT_KCAL = "(kcal)";
public static final String SOURCE_DISTANCE_M = "m";
public static final String SOURCE_DISTANCE_KM = "km";
public static final String SOURCE_DISTANCE_MILE = "mile";
public static final String SOURCE_DISTANCE_UNIT_M = "(m)";
public static final String SOURCE_DISTANCE_UNIT_KM = "(km)";
public static final String SOURCE_DISTANCE_UNIT_MILE = "(mile)";
public static final String SOURCE_SPEED_M = "m/s";
public static final String SOURCE_SPEED_KM = "km/h";
public static final String SOURCE_SPEED_MILE = "mile/h";
public static final String SOURCE_SPEED_UNIT_M = "(m/s)";
public static final String SOURCE_SPEED_UNIT_KM = "(km/h)";
public static final String SOURCE_SPEED_UNIT_MILE = "(mile/h)";
public static final String SOURCE_TEMPERATURE_C = "�C";
public static final String SOURCE_TEMPERATURE_F = "�F";
public static final String SOURCE_TEMPERATURE_K = "�K";
public static final String SOURCE_TEMPERATURE_UNIT_C = "(�C)";
public static final String SOURCE_TEMPERATURE_UNIT_F = "(�F)";
public static final String SOURCE_TEMPERATURE_UNIT_K = "(�K)";
public static final String SOURCE_HUMIDITY_PERCENT = "%";
public static final String SOURCE_HUMIDITY_UNIT_PERCENT = "(%)";
public static final String WEATHER_DISPLAY_TYPE_ICON = "Icon";
public static final String WEATHER_DISPLAY_TYPE_MAIN = "Main";
public static final String WEATHER_DISPLAY_TYPE_DESCRIPTION = "Description";
public static final String WEATHER_DISPLAY_TYPE_NUMBER = "Number";
public static final String WEATHER_DISPLAY_TYPE_ID = "ID";
public static final Source NONE = new Source("None", "none", 0.0D, 0.0D, false, 0.0D, 0.0D, null, new String[] { "None" });
public static final Source HOUR = new Source("Hour in Day", "hour0-23", 0.0D, 24.0D, true, 0.0D, 720.0D, null, new String[] { "%d" });
public static final Source HOUR_MINUTE = new Source("Hour in Day", "hour0-23.minute", 0.0D, 24.0D, true, 0.0D, 720.0D, null, new String[] { "%f" });
public static final Source MINUTE = new Source("Minute in Hours", "minute", 0.0D, 60.0D, false, 0.0D, 360.0D, null, new String[] { "%d" });
public static final Source MINUTE_SECOND = new Source("Minute in Hours", "minute.second", 0.0D, 60.0D, true, 0.0D, 360.0D, null, new String[] { "%f" });
public static final Source SECOND = new Source("Second in Minute", "second", 0.0D, 60.0D, false, 0.0D, 360.0D, null, new String[] { "%d" });
public static final Source SECOND_SWEEP = new Source("Second in Minute", "second.millisecond", 0.0D, 60.0D, true, 0.0D, 360.0D, null, new String[] { "%f" });
public static final Source DAY = new Source("Day of Month", "day", 0.0D, 31.0D, false, 0.0D, 360.0D, null, new String[] { "%d" });
public static final Source MONTH = new Source("Month of Year", "month", 0.0D, 12.0D, false, 0.0D, 360.0D, null, new String[] { "%d" });
public static final Source DAY_OF_WEEK = new Source("Day of Week", "dayOfWeek", 1.0D, 8.0D, false, 0.0D, 360.0D, null, new String[] { "%d" });
public static final Source DAY_OF_YEAR = new Source("Day of Year", "month0-11.day", 0.0D, 12.0D, true, 0.0D, 360.0D, null, new String[] { "%d" });
public static final Source BATTERY_PERCENT = new Source("Battery %", "battery.percent", 0.0D, 100.0D, false, 0.0D, 360.0D,
null, new String[] { "%d %", "%d", "% %d" });
public static final Source BATTERY_LEVEL = new Source("Battery Level", "battery.level", 0.0D, 4.0D, false, 0.0D, 360.0D,
null, new String[] { "%d" });
public static final Source BATTERY_CHARGING_STATUS = new Source("Battery charging status", "battery.chargingStatus", 0.0D, 1.0D, false, 0.0D, 180.0D,
null, new String[] { "%d" });
public static final Source PEDOMETER_STEP_PERCENT = new Source("Steps %", "pedometer.stepPercent", 0.0D, 100.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d %", "%d", "% %d" });
public static final Source PEDOMETER_CALORIE = new Source("Burned calorie", "pedometer.calorie", 0.0D, 1000000.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d kcal",
"%d (kcal)" },
new String[] { "kcal" },
new String[] { "0" },
"kcal", "0");
public static final Source PEDOMETER_DISTANCE = new Source("Moved distance", "pedometer.distance", 0.0D, 10000.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d km",
"%d m",
"%d mile",
"%d (km)",
"%d (m)",
"%d (mile)" },
new String[] { "m", "km", "mile" },
new String[] { "0", "1", "2", "3" },
"km", "1");
public static final Source PEDOMETER_SPEED = new Source("Speed", "stepsPerSec", 0.0D, 20.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d km/h",
"%d m/s",
"%d mile/h",
"%d (km/h)",
"%d (m/s)",
"%d (mile/h)" },
new String[] { "m/s", "km/h", "mile/h" },
new String[] { "0", "1", "2", "3" },
"km/h", "1");
public static final Source PEDOMETER_STEP_COUNT = new Source("Step counts", "pedometer.step", 0.0D, 10000.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d steps", "%d" });
public static final Source PEDOMETER_STEP_GOAL = new Source("Steps goal", "pedometer.target", 0.0D, 100.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d steps", "%d" });
public static final Source PEDOMETER_FLOOR = new Source("Floor", "floor", 0.0D, 100.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d floor", "%d" });
public static final Source HEARTRATE = new Source("Heart rate (bpm)", "heartrate.recent", 0.0D, 200.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d bpm", "%d" });
public static final Source WATER_INTAKE = new Source("Water Intake", "water", 0.0D, 100.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d" });
public static final Source WATER_GOAL = new Source("Water Goal", "water.goal", 0.0D, 100.0D, false, 0.0D, 360.0D,
null, new String[] { "%d" });
public static final Source CAFFEINE_INTAKE = new Source("Caffeine Intake", "caffeine", 0.0D, 100.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/healthinfo", new String[] { "%d" });
public static final Source CAFFEINE_GOAL = new Source("Caffeine Goal", "caffeine.goal", 0.0D, 100.0D, false, 0.0D, 360.0D,
null, new String[] { "%d" });
public static final Source ALARM_HOUR = new Source("Alarm hour", "alarm.hour0-23", 0.0D, 24.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/alarm.get", new String[] { "%d" });
public static final Source ALARM_MINUTE = new Source("Alarm minute", "alarm.minute", 0.0D, 60.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/alarm.get", new String[] { "%d" });
public static final Source ALARM_STATE = new Source("Alarm state", "alarm.state", 0.0D, 2.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/alarm.get", new String[] { "%d" });
public static final Source MOONPHASE_POSITION = new Source("Moon Phase Position", "moonphase.position", 0.0D, 28.0D, true, 0.0D, 360.0D,
null, new String[] { "%f" },
null,
new String[] { "0", "1", "2", "3", "4", "5" },
null, "0");
public static final Source MOONPHASE_TYPE = new Source("Moon Phase Type", "moonphase.type", 0.0D, 8.0D, false, 0.0D, 360.0D,
null, new String[] { "%d" });
public static final Source NOTIFICATION_UNREAD = new Source("Notification unread", "notification.unread", 0.0D, 100.0D, false, 0.0D, 360.0D,
"http://tizen.org/privilege/notification", new String[] { "%d" });
public static final Source WEATHER_TYPE = new Source("Weather Type", "Weather Type", 0.0D, 100.0D, false, 0.0D, 360.0D,
null, new String[] { "Main",
"Icon",
"Description",
"Number",
"ID" });
public static final Source CURRENT_TEMPERATURE = new Source("Current Temperature", "Current Temperature", -50.0D, 50.0D, false, 0.0D, 360.0D,
null, new String[] { "%f �C",
"%f �F",
"%f �K",
"%f (�C)",
"%f (�F)",
"%f (�K)" },
new String[] { "�C", "�F", "�K" },
new String[] { "0", "1", "2", "3" },
"�C", "1");
public static final Source WEATHER_HUMIDITY = new Source("Weather Humidity", "Weather Humidity", 0.0D, 100.0D, false, 0.0D, 360.0D,
null,
new String[] { "%d %",
"%d (%)" },
new String[] { "%" },
new String[] { "0" },
"%", "0");
public static final Source WEATHER_CITY_NAME = new Source("City Name", "City Name", 0.0D, 100.0D, false, 0.0D, 360.0D,
null, new String[] { "%d" });
public static final Source WEATHER_LAST_UPDATE_TIME = new Source("Last update Time", "Last update Time", 0.0D, 100.0D, false, 0.0D, 360.0D,
null, new String[] { "M/d HH:mm", "HH : mm" });
private static final HashMap<String, Source> map = new HashMap();
public final String name;
public final String id;
public double startValue;
public double endValue;
public boolean real;
public double startAngle;
public double endAngle;
public final String privilege;
public final String[] display;
public final String[] unit;
public final String[] precision;
public final String defaultUnit;
public final String defaultPrecision;
static
{
map.put(NONE.id, NONE);
map.put(HOUR_MINUTE.id, HOUR_MINUTE);
map.put(HOUR.id, HOUR);
map.put(MINUTE.id, MINUTE);
map.put(MINUTE_SECOND.id, MINUTE_SECOND);
map.put(SECOND.id, SECOND);
map.put(SECOND_SWEEP.id, SECOND_SWEEP);
map.put(DAY.id, DAY);
map.put(MONTH.id, MONTH);
map.put(DAY_OF_WEEK.id, DAY_OF_WEEK);
map.put(DAY_OF_YEAR.id, DAY_OF_YEAR);
map.put(BATTERY_PERCENT.id, BATTERY_PERCENT);
map.put(BATTERY_LEVEL.id, BATTERY_LEVEL);
map.put(BATTERY_CHARGING_STATUS.id, BATTERY_CHARGING_STATUS);
map.put(PEDOMETER_STEP_PERCENT.id, PEDOMETER_STEP_PERCENT);
map.put(PEDOMETER_CALORIE.id, PEDOMETER_CALORIE);
map.put(PEDOMETER_DISTANCE.id, PEDOMETER_DISTANCE);
map.put(PEDOMETER_SPEED.id, PEDOMETER_SPEED);
map.put(PEDOMETER_STEP_COUNT.id, PEDOMETER_STEP_COUNT);
map.put(PEDOMETER_STEP_GOAL.id, PEDOMETER_STEP_GOAL);
map.put(PEDOMETER_FLOOR.id, PEDOMETER_FLOOR);
map.put(HEARTRATE.id, HEARTRATE);
map.put(WATER_INTAKE.id, WATER_INTAKE);
map.put(WATER_GOAL.id, WATER_GOAL);
map.put(CAFFEINE_INTAKE.id, CAFFEINE_INTAKE);
map.put(CAFFEINE_GOAL.id, CAFFEINE_GOAL);
map.put(ALARM_HOUR.id, ALARM_HOUR);
map.put(ALARM_MINUTE.id, ALARM_MINUTE);
map.put(ALARM_STATE.id, ALARM_STATE);
map.put(MOONPHASE_POSITION.id, MOONPHASE_POSITION);
map.put(MOONPHASE_TYPE.id, MOONPHASE_TYPE);
map.put(NOTIFICATION_UNREAD.id, NOTIFICATION_UNREAD);
map.put(WEATHER_TYPE.id, WEATHER_TYPE);
map.put(CURRENT_TEMPERATURE.id, CURRENT_TEMPERATURE);
map.put(WEATHER_HUMIDITY.id, WEATHER_HUMIDITY);
map.put(WEATHER_CITY_NAME.id, WEATHER_CITY_NAME);
map.put(WEATHER_LAST_UPDATE_TIME.id, WEATHER_LAST_UPDATE_TIME);
map.put(NONE.name, NONE);
map.put(HOUR_MINUTE.name, HOUR_MINUTE);
map.put(HOUR.name, HOUR);
map.put(MINUTE.name, MINUTE);
map.put(MINUTE_SECOND.name, MINUTE_SECOND);
map.put(SECOND.name, SECOND);
map.put(SECOND_SWEEP.name, SECOND_SWEEP);
map.put(DAY.name, DAY);
map.put(MONTH.name, MONTH);
map.put(DAY_OF_WEEK.name, DAY_OF_WEEK);
map.put(DAY_OF_YEAR.name, DAY_OF_YEAR);
map.put(BATTERY_PERCENT.name, BATTERY_PERCENT);
map.put(BATTERY_LEVEL.name, BATTERY_LEVEL);
map.put(BATTERY_CHARGING_STATUS.name, BATTERY_CHARGING_STATUS);
map.put(PEDOMETER_STEP_PERCENT.name, PEDOMETER_STEP_PERCENT);
map.put(PEDOMETER_CALORIE.name, PEDOMETER_CALORIE);
map.put(PEDOMETER_DISTANCE.name, PEDOMETER_DISTANCE);
map.put(PEDOMETER_SPEED.name, PEDOMETER_SPEED);
map.put(PEDOMETER_STEP_COUNT.name, PEDOMETER_STEP_COUNT);
map.put(PEDOMETER_STEP_GOAL.name, PEDOMETER_STEP_GOAL);
map.put(PEDOMETER_FLOOR.name, PEDOMETER_FLOOR);
map.put(HEARTRATE.name, HEARTRATE);
map.put(WATER_INTAKE.name, WATER_INTAKE);
map.put(WATER_GOAL.name, WATER_GOAL);
map.put(CAFFEINE_INTAKE.name, CAFFEINE_INTAKE);
map.put(CAFFEINE_GOAL.name, CAFFEINE_GOAL);
map.put(ALARM_HOUR.name, ALARM_HOUR);
map.put(ALARM_MINUTE.name, ALARM_MINUTE);
map.put(ALARM_STATE.name, ALARM_STATE);
map.put(MOONPHASE_POSITION.name, MOONPHASE_POSITION);
map.put(MOONPHASE_TYPE.name, MOONPHASE_TYPE);
map.put(NOTIFICATION_UNREAD.name, NOTIFICATION_UNREAD);
map.put(WEATHER_TYPE.name, WEATHER_TYPE);
map.put(CURRENT_TEMPERATURE.name, CURRENT_TEMPERATURE);
map.put(WEATHER_HUMIDITY.name, WEATHER_HUMIDITY);
map.put(WEATHER_CITY_NAME.name, WEATHER_CITY_NAME);
map.put(WEATHER_LAST_UPDATE_TIME.name, WEATHER_LAST_UPDATE_TIME);
}
public Source(String name, String id, double startValue, double endValue, boolean real, double startAngle, double endAngle, String privilege, String[] display, String[] unit, String[] precision, String defaultUnit, String defaultPrecision)
{
this.name = name;
this.id = id;
this.startValue = startValue;
this.endValue = endValue;
this.real = real;
this.startAngle = startAngle;
this.endAngle = endAngle;
this.privilege = privilege;
this.display = display;
this.unit = unit;
this.precision = precision;
this.defaultUnit = defaultUnit;
this.defaultPrecision = defaultPrecision;
}
public Source(String name, String id, double startValue, double endValue, boolean real, double startAngle, double endAngle, String privilege, String[] display)
{
this(name, id, startValue, endValue, real, startAngle, endAngle, privilege, display, null, null, null, null);
}
public Source(Source source)
{
this(source.name, source.id, source.startValue, source.endValue, source.real, source.startAngle, source.endAngle, source.privilege, source.display, source.unit, source.precision, source.defaultUnit, source.defaultPrecision);
}
public boolean equals(Object obj)
{
if ((obj instanceof Source)) {
return (this.name.equals(((Source)obj).name)) && (this.id.equals(((Source)obj).id)) &&
(this.startValue == ((Source)obj).startValue) && (this.endValue == ((Source)obj).endValue) && (this.real == ((Source)obj).real) &&
(this.startAngle == ((Source)obj).startAngle) && (this.endAngle == ((Source)obj).endAngle);
}
return false;
}
public static Source findById(String id)
{
Source result = (Source)map.get(id);
if (result == null) {
return NONE;
}
return result;
}
public static Source findByName(String name)
{
return (Source)map.get(name);
}
}

Categories

Resources