issue #958 closed

parent 10c0dae0
......@@ -399,24 +399,24 @@ public class Vocabulary implements Iterable<Picto> {
/*
* It saves locally a new picto obtained from the PCB
*/
public Picto saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y, final iLocalPicto listener) {
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y, final iLocalPicto listener) {
Picto prev_picto=find_picto(cat, coord_x,coord_y); //¿estamos reemplazanddo un picto que ya existe?
if (prev_picto!=null) { //El picto ya existe
removePicto(prev_picto.get_category(),prev_picto.get_id()); //borramos el picto local actual
Log.i(LOG_TAG,"Picto "+exp+" already exists. Previous local picto "+prev_picto.get_id()+" is deleted.");
Log.i(LOG_TAG,"Picto "+exp+" position is filled with "+prev_picto.get_translation()+"(id "+prev_picto.get_id()+"). Previous local picto "+prev_picto.get_id()+" is deleted.");
}
int id=PCBcontext.getDevice().getNextLocalPictoID();
final Picto picto[]=new Picto[1];
try {
picto[0] = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y, prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL);
addPicto(picto[0], ImgDownloader.tsource.local, new ImgDownloader.iImgDownloaderListener() {
final Picto picto = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y, prev_picto!=null ? prev_picto.get_stupicto_id() : Picto.STUPICTO_NULL);
addPicto(picto, ImgDownloader.tsource.local, new ImgDownloader.iImgDownloaderListener() {
@Override
public void loadComplete() {
listener.saved(picto[0]);
listener.saved(picto);
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ADD, picto));
}
@Override
public void loadImg(Img image) {
......@@ -428,12 +428,10 @@ public class Vocabulary implements Iterable<Picto> {
}
});
} catch (Exception e) {
picto[0]=null;
e.printStackTrace();
Log.e(Vocabulary.class.getCanonicalName(), e.getMessage());
}
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ADD, picto[0]));
return picto[0];
}
/**
......
......@@ -174,7 +174,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
Log.e(LOG_TAG, "New version is required! from v" + DeviceHelper.getAppVersion(PCBcontext.getContext()) + " to v" + version);
newVersionAlert(PCBcontext.getActivityContext(), version);
}
} catch (JSONException e) {
} catch (Exception e) {
Log.e(LOG_TAG, "PING JSON ERROR: " + result + " " + e.getMessage());
}
if (!updated) {
......
......@@ -317,8 +317,7 @@ public class PictoUploader {
GUITools.show_alert(PCBcontext.getActivityContext(), errmsg, PictoUploader.this.picto.get_translation());
}
if (elements_uploaded == elements_to_be_uploaded) {
PCBcontext.getVocabulary().removePicto(picto.get_category(), local_img_id);
PictoUploader.this.picto.delete_bitmap(PCBcontext.getContext());
PCBcontext.getPcbdb().deletePicto(local_img_id);
PCBcontext.getVocabulary().addPicto(picto);
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, PictoUploader.this.picto));
GUITools.show_alert(PCBcontext.getActivityContext(), R.string.upload_ok,PictoUploader.this.picto.get_translation());
......
......@@ -134,6 +134,11 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
super.onCreate(savedInstanceState);
// blockNotificationBar();
requestWindowFeature(Window.FEATURE_NO_TITLE);
// after a long inactivity, the pcbdb is discarded
if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG,"PCBDB was discarded. App restarting");
NetServiceTablet.restart_PictogramTablet(null,false);
}
setContentView(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? R.layout.activity_pictogram_big : R.layout.activity_pictogram);
this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout);
......
package com.yottacode.pictogram.tabletlibrary.net;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;
import com.yottacode.pictogram.dao.User;
......@@ -22,6 +20,7 @@ import com.yottacode.pictogram.tools.PCBcontext;
public class NetServiceTablet implements NetService.iNetServiceDevice {
private static final String LOG_TAG = NetServiceTablet.class.getName();
private static NotificationCompat.Builder builder;
private PictogramActivity pictogramActivity;
int notifyID = 666;
......@@ -66,20 +65,24 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
}
/**
* if the user becomes from offline to online and the login is failed, then the user relogin in
* the app. The most frequent reason is a password change while the user have been logged
* offline
*/
public void restart_app(Intent serialActivity, boolean direct_login) {
/**
* if the user becomes from offline to online and the login is failed, then the user relogin in
* the app. The most frequent reason is a password change while the user have been logged
* offline
*/
public void restart_app(Intent serialActivity, boolean direct_login) {
NetServiceTablet.restart_PictogramTablet(serialActivity,direct_login);
}
public static void restart_PictogramTablet(Intent serialActivity, boolean direct_login) {
Log.i(this.getClass().getCanonicalName(),"App restarting");
Log.i(LOG_TAG,"App restarting");
if (serialActivity==null) {
Class serialClass;
try {
serialClass=Class.forName(PCBcontext.getContext().getString(R.string.SerialClass));
} catch (ClassNotFoundException e) {
Log.e(this.getClass().getCanonicalName(),"S:"+PCBcontext.getContext().getString(R.string.SerialClass));
Log.e(LOG_TAG,"S:"+PCBcontext.getContext().getString(R.string.SerialClass));
serialClass=SerialActivity.class;
}
serialActivity = new Intent(PCBcontext.getContext(), serialClass);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment