Skip to content
This repository has been archived by the owner on Apr 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4 from firesoft-de/dev
Browse files Browse the repository at this point in the history
Version 0.3 überführen
  • Loading branch information
firesoft-de authored Jan 7, 2018
2 parents 970a8b3 + 9dc358b commit 6e917eb
Show file tree
Hide file tree
Showing 40 changed files with 1,119 additions and 226 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ server/skripte/access.txt
*.csv
*.sql
server/Datenbank
Vorstellung
server/skripte/config/.htaccess
Binary file modified DiTaKa/app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion DiTaKa/app/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":2},"path":"app-release.apk","properties":{"packageId":"dresden.de.digitaleTaschenkarteBeladung","split":"","minSdkVersion":"18"}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":3},"path":"app-release.apk","properties":{"packageId":"dresden.de.digitaleTaschenkarteBeladung","split":"","minSdkVersion":"18"}}]
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "8bb730f64364aeaccecb4f4c62685f60",
"identityHash": "be02c646ae3738ad34d4c2024d34e168",
"entities": [
{
"tableName": "equipment",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT, `description` TEXT, `categoryId` INTEGER NOT NULL, `mSetName` TEXT, `position` TEXT, `keywords` TEXT, `additionalNotes` TEXT, PRIMARY KEY(`id`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT, `description` TEXT, `categoryId` INTEGER NOT NULL, `mSetName` TEXT, `position` TEXT, `keywords` TEXT, `additionalNotes` TEXT, `positionIndex` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
Expand Down Expand Up @@ -55,6 +55,12 @@
"columnName": "additionalNotes",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "positionIndex",
"columnName": "positionIndex",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
Expand All @@ -68,7 +74,7 @@
},
{
"tableName": "tray",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT, `description` TEXT, `descriptionTwo` TEXT, `position` TEXT, PRIMARY KEY(`id`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `name` TEXT, `description` TEXT, `descriptionTwo` TEXT, `positions` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
Expand All @@ -95,10 +101,42 @@
"notNull": false
},
{
"fieldPath": "position",
"columnName": "position",
"fieldPath": "positionCoordinates",
"columnName": "positions",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "image",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `path` TEXT, `categoryID` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "path",
"columnName": "path",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "categoryID",
"columnName": "categoryID",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
Expand All @@ -113,7 +151,7 @@
],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"8bb730f64364aeaccecb4f4c62685f60\")"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"be02c646ae3738ad34d4c2024d34e168\")"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MainActivity extends AppCompatActivity implements TrayFragment.frag
//DEBUG Konstanten
private final static String LOG_TAG="MainActivity_LOG";
//TODO: Debug ausschalten
public final static Boolean DEBUG_ENABLED = true;
public final static Boolean DEBUG_ENABLED = false;

//Globale Variablen
private FragmentManager fManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import android.arch.lifecycle.ViewModelProvider;
import android.arch.lifecycle.ViewModelProviders;
import android.content.Intent;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;
Expand Down Expand Up @@ -53,6 +55,8 @@ public class SearchableActivity extends AppCompatActivity implements TrayFragme
@Inject
ViewModelProvider.Factory viewModelFactory;

//Diese Variable wird zum Speichern des Scroll Index der ListView gebraucht
Parcelable state;

public MutableLiveData<List<DatabaseEquipmentMininmal>> liveItemList;

Expand Down Expand Up @@ -243,6 +247,14 @@ public void onBackPressed() {
}
}

@Override
protected void onPause() {
ListView lv = this.findViewById(R.id.ListViewSearch);

state = lv.onSaveInstanceState();
super.onPause();
}

private void returnToMainActivity() {
Intent intent = new Intent(this, MainActivity.class);
intent.setAction(Intent.ACTION_MAIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Diese Klasse vereint das Datenbankobjeckt und die DAO Klasse
*/
@Database(entities = {EquipmentItem.class, TrayItem.class}, version = 1)
@Database(entities = {EquipmentItem.class, TrayItem.class, ImageItem.class}, version = 1)
@TypeConverters({Converters.class})
public abstract class DatabaseClass extends RoomDatabase{
public abstract DatabaseDAO equipmentDAO();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.TypeConverter;
import android.arch.persistence.room.TypeConverters;
import android.arch.persistence.room.Update;
import android.media.Image;

import java.util.List;

Expand Down Expand Up @@ -71,4 +74,32 @@ public interface DatabaseDAO {

@Query("SELECT COUNT(id) FROM tray")
LiveData<Integer> countTrays();

@Query("SELECT * FROM tray WHERE id LIKE :id")
LiveData<TrayItem> getTrayById(int id);

// @Query("SELECT positions FROM tray WHERE id LIKE :id")
// @TypeConverters(Converters.class)
// LiveData<List<Integer>> getPositionCoordinates(int id);


//DAO für Image
@Query("SELECT COUNT(id) FROM image")
LiveData<Integer> countImage();

@Query("SELECT * FROM image")
LiveData<List<ImageItem>> getAllImages();

@Query("SELECT * FROM image WHERE id LIKE :id")
LiveData<ImageItem> findImageByID(int id);

@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertImages(ImageItem image);

@Query("DELETE FROM image")
void deleteImage();

@Query("SELECT * FROM image WHERE categoryId LIKE :id")
LiveData<ImageItem> getImageByCatID(int id);

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,20 @@ public void deleteItem(int id) {

public LiveData<Integer> countTrays() {return daoObject.countTrays();}

public LiveData<TrayItem> getTrayById(int id) {return daoObject.getTrayById(id);}



public LiveData<Integer> countImage(){return daoObject.countImage();}

public LiveData<ImageItem> getImageByID(int id) {return daoObject.findImageByID(id);}

public void deleteAllImages() {daoObject.deleteImage();}

public void add(ImageItem imageItem) {daoObject.insertImages(imageItem);}

public LiveData<ImageItem> getImageByCatID(int catID) {return daoObject.getImageByCatID(catID);}

// public LiveData<List<Integer>> getPositionCoordinates(int catID) {return daoObject.getPositionCoordinates(catID);}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONArray;
import org.json.JSONException;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -54,6 +57,8 @@ public class EquipmentItem implements Parcelable {
//Zusätzliche Hinweise zum Gerät
private String additionalNotes;

//Index der Koordinaten für die Positionsmarkierung. Die Liste der Koordinaten wird im TrayItem gespeichert
private int positionIndex;

public static final Parcelable.Creator<EquipmentItem> CREATOR
= new Parcelable.Creator<EquipmentItem>() {
Expand Down Expand Up @@ -155,6 +160,10 @@ public EquipmentItem(Parcel input) {

public String getAdditionalNotes() {return additionalNotes;}

public int getPositionIndex() {
return positionIndex;
}

//Set Methoden

public void setId(int id) {}
Expand Down Expand Up @@ -183,6 +192,10 @@ public void setKeywordsFromArray(String[] keywords) {
this.keywords = list;
}

public void setPositionIndex(int positionIndex) {
this.positionIndex = positionIndex;
}



// public void setImage(Image image) {mImage = image;}
Expand Down Expand Up @@ -223,7 +236,6 @@ public void fromMinimal(DatabaseEquipmentMininmal minimal) {
this.name = minimal.name;
this.position = minimal.position;
}

}

class Converters {
Expand All @@ -235,8 +247,49 @@ public static ArrayList<String> fromJSON(String value) {

@TypeConverter
public static String fromArray(ArrayList<String> list) {

Gson gson = new Gson();
String json = gson.toJson(list);
return json;
}

@TypeConverter
public static ArrayList<Integer> fromJSONToInt(String value) {

if (value != null) {
ArrayList<Integer> list = new ArrayList<>();
JSONArray array = null;

try {
array = new JSONArray(value);
} catch (JSONException e) {
e.printStackTrace();
} finally {
for (int i = 0; i < array.length(); i++) {
try {
list.add(array.getInt(i));
} catch (JSONException e) {
e.printStackTrace();
}
}
return list;
}
}
return null;
}

@TypeConverter
public static String fromArrayToJSON(ArrayList<Integer> list) {
JSONArray array = new JSONArray();

if (list != null) {
for (int value : list) {
array.put(value);
}
return array.toString();
}
else {
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package dresden.de.digitaleTaschenkarteBeladung.data;


import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;
import android.graphics.Bitmap;

@Entity(tableName = "image")
public class ImageItem {

@PrimaryKey
private int id;

private String path;
private int categoryID;

// @Ignore
// private Bitmap image;

public ImageItem(int id, String path, int categoryID) {
this.id = id;
this.path = path;
this.categoryID = categoryID;
}

public void setId(int id) {}
public void setPath(String path) {this.path = path;}
public void setCategoryID(int categoryID) {this.categoryID = categoryID;}
// public void setImage(Bitmap bitmap) {this.image = bitmap;}

public int getId() {return id;}
public String getPath() {return path;}
public int getCategoryID() {return categoryID;}


// public Bitmap getImage() {return image;}
}
Loading

0 comments on commit 6e917eb

Please sign in to comment.