Posts

android - How to start video from where it stopped -

i using videoview playing video. if go out of application, while returning application ie in onresume() should play video stopped. to current progress(check in onpause): long progress = mvideoview.getcurrentposition(); to resume (in onresume): mvideoview.seekto(progress);

arrays - Mongodb query doesn't work -

in image sharing application can upload images , create albums. when delete image site shall deleted in albums (the ones has got image in it). below route deleting image, , need why code deleting images (imagename , imageid) in albums below doesn't work. thanks in advance! the models: var albumschema = new schema({ title : string, imagename : [string], imageid : [string] }); modelobject.albumschema = albumschema; modelobject.album = mongoose.model('album', albumschema); - var blogpostschema = new schema({ name : string, size : number, type : string, author : objectid, title : string }); modelobject.comment = mongoose.model('comment', commentschema); modelobject.blogpost = mongoose.model('blogpost', blogpostschema); the part doesn't work in code below following: albums[i].imagename.remove(j); albums[i].imageid.remove(j); albums[i].save(f...

activerecord - rails fields_for object is nil, when I try to access an attribute -

have 3 models: class offer < activerecord::base has_many :offer_items end class offeritem < activerecord::base belongs_to :offer belongs_to :partner_product accepts_nested_attributes_for :partner_product end class partnerproduct < activerecord::base has_many :offer_items accepts_nested_attributes_for :offer_items end in form offer edited, there fields_for edit offer_item <% f.fields_for :offer_items |offer_item_form| -%> <div class='offer_item'> <%= render :partial => 'offer_item_fields', :locals => {:offer_item_form => offer_item_form}%> </div> <% end -%> the code chunk in partial: <%= offer_item_form.object.partner_product.name%> throws error undefined method `name' nil:nilclass extracted source (around line #29): <%= offer_item_form.object.partner_product.name%> but when don't ask name, this <%= offer_item_form.object.partner_product%> ...

ruby on rails - How do I add a data association between records in a HABTM many to many relationship? -

i have set habtm relationship between 2 table creating many many relationship between items , categories. want add item connected 1 or more categories via add item form. when submit form getting error "can't mass-assign protected attributes: categories". here models: class item < activerecord::base attr_accessible :description, :image, :name has_attached_file :image, :styles => { :medium => "300x300>", :thumb => "100x100>" } belongs_to :user has_and_belongs_to_many :categories validates :name, presence: true, length: {maximum: 50} accepts_nested_attributes_for :categories end class category < activerecord::base attr_accessible :description, :name has_and_belongs_to_many :items validates :name, presence: true, length: {maximum: 50} end and migrations: class createitems < activerecord::migration def change create_table :items |t| t.string :name t.text :description t.has_a...

android - Implementing callback from Service to Activity -

this question has answer here: accessing ui thread handler service 5 answers i have been playing service , cannot them run need. need call service functions activity , , use this public class localbinder extends binder { localservice getservice() { return localservice.this; } } but how callback activity once long network operation done? i want show spinner on action bar while service something, , when finishes hide it. need persist on different activities have same action bar. also, serviceconnection asynchronous callback, how bind service, wait callback and then change case case function of service call? well , call service's function synchrounous , implementation of function on service can asynchrounous (for example , using asynctask ) , when result finished , can either send intent , or call listener stored call .

python - Django 1.2: How to connect pre_save signal to class method -

i trying define "before_save" method in classes in django 1.2 project. i'm having trouble connecting signal class method in models.py. class myclass(models.model): .... def before_save(self, sender, instance, *args, **kwargs): self.test_field = "it worked" i've tried putting pre_save.connect(before_save, sender='self') in 'myclass' itself, nothing happens. i've tried putting @ bottom of models.py file: pre_save.connect(myclass.before_save, sender=myclass) i read connecting signals class methods here , can't figure out code. anybody know i'm doing wrong? rather use method on myclass, should use function. like: def before_save(sender, instance, *args, **kwargs): instance.test_field = "it worked" pre_save.connect(before_save, sender=myclass)

ios - How to delete call history details using tableview editing method in iPhone -

i new in iphone application development. developing call history application in iphone. in application fetching call details using call history database, , displaying in table view. want perform delete on selected row call history value in database. don't know how perform operation. using following code showing error like: terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'error while creating delete statement. 'near "<": syntax error'' - (void)tableview:(uitableview *)atableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { if (editingstyle == uitableviewcelleditingstyledelete) { [appdelegate.displayhistroryvalueappdelegate removeobjectatindex:indexpath.row]; [displaytableview reloaddata]; int rowid = [[[appdelegate.displayhistroryvalueappdelegate objectatindex:indexpath.row]valueforkey:@"rowid"] intv...