Browse Source

Fix Downloaded binaries

tags/release-v1.0
Schoumi 3 years ago
parent
commit
3c6d37efd1

+ 1
- 1
app/src/main/java/fr/mobdev/lpcprog/fragment/DeviceFragment.java View File

@@ -345,7 +345,7 @@ public class DeviceFragment extends Fragment {
}
});
msg.show();
List<List<Server>> localServers = DatabaseManager.getInstance(getActivity()).getServers();
List<List<Server>> localServers = DatabaseManager.getInstance(getActivity()).getServers(getActivity());
servers.addAll(localServers.get(0));
servers.addAll(localServers.get(1));
servers.addAll(localServers.get(2));

+ 1
- 1
app/src/main/java/fr/mobdev/lpcprog/fragment/ServersFragment.java View File

@@ -84,7 +84,7 @@ public class ServersFragment extends Fragment {
public void updateServers(View v)
{
// build the view with server list in database
List<List<Server>> dbServers = DatabaseManager.getInstance(getActivity()).getServers();
List<List<Server>> dbServers = DatabaseManager.getInstance(getActivity()).getServers(getActivity());
List<String> namesList = new ArrayList<>();
namesList.add(getString(R.string.active_section));
namesList.add(getString(R.string.inactive_section));

+ 6
- 4
app/src/main/java/fr/mobdev/lpcprog/managers/DatabaseManager.java View File

@@ -24,6 +24,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@@ -167,7 +168,7 @@ public class DatabaseManager extends SQLiteOpenHelper {
getWritableDatabase().delete("servers",where,whereArgs);
}

public List<List<Server>> getServers() {
public List<List<Server>> getServers(Context context) {
List<List<Server>> list = new ArrayList<>();
List<Server> active = new ArrayList<>();
List<Server> inactive = new ArrayList<>();
@@ -185,7 +186,7 @@ public class DatabaseManager extends SQLiteOpenHelper {
int isActive = cursor.getInt(col++);
server.isActive = isActive != 0;
server.attempted = cursor.getInt(col);
server.binaries = getBinaries(server.id);
server.binaries = getBinaries(context, server.id);
if (server.isActive && server.attempted == 0)
active.add(server);
else if (server.isActive && server.attempted != 0)
@@ -200,7 +201,7 @@ public class DatabaseManager extends SQLiteOpenHelper {
return list;
}

private List<Binary> getBinaries(long id) {
private List<Binary> getBinaries(Context context, long id) {
List<Binary> binaries = new ArrayList<>();
String whereClause = "server_id = ?";
String[] whereArgs = new String[1];
@@ -217,7 +218,8 @@ public class DatabaseManager extends SQLiteOpenHelper {
b.version = cursor.getInt(col++);
b.path = cursor.getString(col++);
b.sha1 = cursor.getString(col);
b.isDownloaded = true;
File file = new File(context.getApplicationInfo().dataDir+"/"+id+"/"+b.path+b.filename);
b.isDownloaded = file.exists();
b.progress = 0;
b.isDownloading = false;
binaries.add(b);

+ 1
- 1
app/src/main/java/fr/mobdev/lpcprog/managers/NetworkManager.java View File

@@ -104,7 +104,7 @@ public class NetworkManager {
}

private void getBinariesList(){
List<List<Server>> servers = DatabaseManager.getInstance(context).getServers();
List<List<Server>> servers = DatabaseManager.getInstance(context).getServers(context);
List<Server> serversAvailable = new ArrayList<>();
for(Server server : servers.get(0)){
serversAvailable.add(server);

Loading…
Cancel
Save