how i can set current date and time as wallpaper in android pragmatically? - live-wallpaper

i wants to set current date and time as a wall paper in android problematically.
how it is possible kindly help me , thanks in advance.

Now you can call 'showCurrentTime();' whenever you want. Don't forget to update this every second! :)
void showCurrentTime() {
final SurfaceHolder holder = getSurfaceHolder();
Canvas c = null;
try {
c = holder.lockCanvas();
if (c !=null) {
c.save();
c.drawColor(0xff000000);
c.drawText(new Date(System.currentTimeMillis()).toLocaleString(), mTouchX, mTouchY, mPaint);
c.restore();
}
} finally {
if (c != null) {
holder.unlockCanvasAndPost(c);
}
}
}

Related

Google Apps Scripting Running a Script Based on a Variable

Okay, I've been a coding for a little while and have had the chance to do a number of things.
One issue I'd like to find a more elegant way is running scripts based on the value of a variable.
At the moment I'm doing it like this.
if (ScriptName == 'overnightRun' ) {
overnightRun();
}
if (ScriptName == 'resetAnalysisSheets' ) {
resetAnalysisSheets();
}
if (ScriptName == 'resetActiveSheetFormulae' ) {
resetActiveSheetFormulae();
}
if (ScriptName == 'saveRemainingContractSheets' ) {
saveRemainingContractSheets();
}
if (ScriptName == 'saveAllContractSheets' ) {
saveAllContractSheets();
}
if (ScriptName == 'saveCurrentContractSheet' ) {
saveCurrentContractSheet();
}
if (ScriptName == 'clearDataSheets' ) {
clearDataSheets();
}
Surely there must be a better way. Something more like this.
run.script(ScriptName);
Anyone any ideas? Thanks for reading!
You could try this:
function testFunction() {
var ScriptName = "Alibaba";
var p = "Open sesame!"
this[ScriptName](p);
}
function Alibaba(p) {
Logger.log(p);
}
Leave the parameter p blank if nothing is to be passed.

how to apply condition on all frames?

I want to apply this condition on all frame of adobe flash cs 6:
if(pauseMusic.visible==true) {
playMusic.visible=false;
} else if(pauseMusic.visible==false) {
playMusic.visible=true;
}
But I don't want to copy it one by one of frame actions. What cant I do?
!
create a function in your first frame
if you have more than one frame in your time line, at the first frame insert it:
if(this._condition == null) {
this._condition = function():void {
if(pauseMusic.visible==true) {
playMusic.visible=false;
} else if(pauseMusic.visible==false) {
playMusic.visible=true;
}
}
}
and simply call it in other frames : this._condition();
I agree with #payamsbr but this is shorter...
_condition = function():void {
pauseMusic.visible = !pauseMusic.visible;
}
So you may avoid the if... else... check.
The initial Boolean should be defined to
true or false
So all You have to do is to call
_condition();
[EDIT]
OR in case of uint 1 ->-1 or -1 to 1:
var i:uint=1
function changeUint():void{
i = *=-1
}
changeUint();
-> 1 to -1 or -1 to 1
1 to -1 or -1 to 1...
[/EDIT]
But You want to check if the function exist as he said.
I used this function in first frame:
stage.addEventListener(Event.ENTER_FRAME, onFrameEnter);
function onFrameEnter(Event):void
{
if(pauseMusic.visible==true)
{
playMusic.visible=false;
}
else if(pauseMusic.visible==false)
{
playMusic.visible=true;
}
}

Windows Phone MultiSelect ListBox selected items

For about three hours, I've been trying to get selected indexes of a multiselect listbox. I tried variety of solutions but they don't work. The final thing I've found is the following;
for (int i = 0; i < this.myListBox.Items.Count; i++)
{
ListBoxItem currentItem = this.myListBox.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem;
if (currentItem != null && currentItem.IsSelected)
{
ApplicationManager.Instance.getContactManager().addToIndexes(i);
}
}
This seems to work but when I scroll-down in the list for example, listboxitem of previously selected items returns null. How can I accomplish this task?
As per my understanding of your question you require selected index...
so you have to use List box tap event and than find selected index
for example
private void mylistbox_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
{
List<ClsReportId> lstrptId = new List<ClsReportId>();
ListBox lst = (ListBox)sender;
int i = lst.SelectedIndex;
if (lst.SelectedValue == null)
{
}
else
{
ClsGetSubmittedReport cls = (ClsGetSubmittedReport)lst.SelectedValue;
reportId = cls.ReportId1.ToString();
}
}
Hope it will help you
Thanks

Auto manage and protect Created\Updated fields with Entity Framework 5

I want so every added\changed record will have a time stamp of creation\change.
But - so it will be easy to embed and easy to manage - automatically.
Overwrite the 'DbContext' class or embed this in the '.tt' file (Codefirst \ DBFirst)
The code assume so you have the fields 'CreatedOn'\'ModifiedOn' inside the POCO.
If you don't have them, or you have only one - the code will work fine.
Be aware! If you use a extension (as this one) so allow you to do batch updates or changes from a stored procedure - this will not work
EDIT:
I found the source of my inspiration - thanks 'Nick' here
public override int SaveChanges()
{
var context = ((IObjectContextAdapter)this).ObjectContext;
var currentTime = DateTime.Now;
var objectStateEntries = from v in context.ObjectStateManager.GetObjectStateEntries(EntityState.Added | EntityState.Modified)
where v.IsRelationship == false && v.Entity != null
select v;
foreach (var entry in objectStateEntries)
{
var createdOnProp = entry.Entity.GetType().GetProperty("CreatedOn");
if (createdOnProp != null)
{
if (entry.State == EntityState.Added)
{
if (createdOnProp != null)
{
createdOnProp.SetValue(entry.Entity, currentTime);
}
}
else
{
Entry(entry.Entity).Property("CreatedOn").IsModified = false;
}
}
var modifiedOnProp = entry.Entity.GetType().GetProperty("ModifiedOn");
if (modifiedOnProp != null)
{
modifiedOnProp.SetValue(entry.Entity, currentTime);
}
}
return base.SaveChanges();
}

Actions Script 3.0 if else statements

need to do several things by it's click event. I'm a beginner to this, so is there any other way to write this code? by clicking this button, it goes to next frame and according to statement several buttons will be visible or not. I wrote the code this way and it says there are syntax error, but I couldn't find any. Hope you guys understand this and will help me. :) Thank you!
review_btn.addEventListener(MouseEvent.CLICK, review1)
function review1(event:MouseEvent):void{
if(rvw1 == "Correct"){
gotoAndStop(3627);
help1.visible = false
}
else{
gotoAndStop(3627);
help1.visible = true
}
}
review_btn.addEventListener(MouseEvent.CLICK, review2)
function review2(event:MouseEvent):void{
if(rvw2 == "Correct"){
gotoAndStop(3627);
help2.visible = false
}
else{
gotoAndStop(3627);
help2.visible = true
}
}
review_btn.addEventListener(MouseEvent.CLICK, review3)
function review3(event:MouseEvent):void{
if(rvw3 == "Correct"){
gotoAndStop(3627);
help3.visible = false
}
else{
gotoAndStop(3627);
help3.visible = true
}
}
review_btn.addEventListener(MouseEvent.CLICK, review4)
function review4(event:MouseEvent):void{
if(rvw4 == "Correct"){
gotoAndStop(3627);
help4.visible = false
}
else{
gotoAndStop(3627);
help4.visible = true
}
}
review_btn.addEventListener(MouseEvent.CLICK, review5)
function review5(event:MouseEvent):void{
if(rvw5 == "Correct"){
gotoAndStop(3627);
help5.visible = false
}
else{
gotoAndStop(3627);
help5.visible = true
}
}
I'll take an attempt at it. It looks like the only difference is that in each method you need to match up "helpX".visible with "rvwX" equals the string "Correct", where X is a number from 1-5. The gotoAndStop() frame is the same regardless. Also, that all five are meant to be off the same button. I'm going to take an assumption that the clips 'help' are movieclips defined on the stage else if they are from something else I would store them in an array for looping through instead of 'building' the name and finding the reference that way just for clarity.
function review(event:MouseEvent):void {
for(var counter:int = 1; counter < 6; counter++){
this["help" + counter].visible = (this["rvw" + counter] != "Correct");
}
this.gotoAndStop(3627);
}
review_btn.addEventListener(MouseEvent.CLICK, review);
I think you have to do a class with 2 fields: "help" and "rvw" (let me call it "Switcher"). Also it may contain a function of setting visibility (may, not must, this function can also be in your main class):
Switcher.as:
import flash.display.MovieClip;
public class Switcher {
private var help:MovieClip;
private var rvw:String;
public function setVisibility() {
help.visible = !(rvw == "Correct");
}
}
Then you have to make an array of Switcher's objects in your main class and to use only one "review" handler:
function review(event:MouseEvent):void {
for each(var sw:Switcher in switchersArray) {
sw.setVisibility();
}
this.gotoAndStop(3627);
}
The code from previous answer will work correctly, but IMHO, creating an Array (or Vector) of similar objects is better than doing lots of help1, help2, help3 etc variables.