Don't show "Error" when a blank string is returned from a native method.

This commit is contained in:
Eder Bastos 2015-05-10 10:46:46 -04:00
parent 3f1465196c
commit ca4bec3539
3 changed files with 78 additions and 60 deletions

View File

@ -15,6 +15,10 @@ import org.dolphinemu.dolphinemu.BuildConfig;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.adapters.FileAdapter;
/**
* An Activity that shows a list of files and folders, allowing the user to tell the app which folder(s)
* contains the user's games.
*/
public class AddDirectoryActivity extends Activity implements FileAdapter.FileClickListener
{
public static final String KEY_CURRENT_PATH = BuildConfig.APPLICATION_ID + ".path";
@ -74,6 +78,7 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl
return super.onOptionsItemSelected(item);
}
@Override
protected void onSaveInstanceState(Bundle outState)
{
@ -83,6 +88,9 @@ public class AddDirectoryActivity extends Activity implements FileAdapter.FileCl
outState.putString(KEY_CURRENT_PATH, mAdapter.getPath());
}
/**
* Tell the GameGridActivity that launched this Activity that the user picked a folder.
*/
@Override
public void finishSuccessfully()
{

View File

@ -3,16 +3,11 @@ package org.dolphinemu.dolphinemu.activities;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.DocumentsContract;
import android.provider.OpenableColumns;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
@ -32,6 +27,10 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
* The main Activity of the Lollipop style UI. Shows a grid of games on tablets & landscape phones,
* shows a list of games on portrait phones.
*/
public final class GameGridActivity extends Activity
{
private static final int REQUEST_ADD_DIRECTORY = 1;
@ -83,21 +82,33 @@ public final class GameGridActivity extends Activity
}
}
/**
* Callback from AddDirectoryActivity. Applies any changes necessary to the GameGridActivity.
*
* @param requestCode
* @param resultCode
* @param result
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent result)
{
// If the user picked a file, as opposed to just backing out.
if (resultCode == RESULT_OK)
{
// Sanity check to make sure the Activity that just returned was the AddDirectoryActivity;
// other activities might use this callback in the future (don't forget to change Javadoc!)
if (requestCode == REQUEST_ADD_DIRECTORY)
{
String path = result.getStringExtra(AddDirectoryActivity.KEY_CURRENT_PATH);
// Store this path as a preference.
// TODO Use SQLite instead.
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = prefs.edit();
editor.putString(AddDirectoryActivity.KEY_CURRENT_PATH, path);
// Using commit in order to block so the next method has the correct data to load.
// Using commit, not apply, in order to block so the next method has the correct data to load.
editor.commit();
mAdapter.setGameList(getGameList());

View File

@ -219,7 +219,7 @@ static std::string GetTitle(std::string filename)
return name;
}
return std::string ("Error");
return std::string ("");
}
static std::string GetDescription(std::string filename)
@ -256,7 +256,7 @@ static std::string GetDescription(std::string filename)
return descriptions.cbegin()->second;
}
return std::string ("Error");
return std::string ("");
}
static std::string GetGameId(std::string filename)
@ -271,7 +271,7 @@ static std::string GetGameId(std::string filename)
return id;
}
return std::string ("Error");
return std::string ("");
}
static std::string GetApploaderDate(std::string filename)
@ -286,7 +286,7 @@ static std::string GetApploaderDate(std::string filename)
return date;
}
return std::string ("Error");
return std::string ("");
}
static u64 GetFileSize(std::string filename)
@ -460,8 +460,7 @@ JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetConfig
return env->NewStringUTF(value.c_str());
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey,
jstring jValue)
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetConfig(JNIEnv *env, jobject obj, jstring jFile, jstring jSection, jstring jKey, jstring jValue)
{
IniFile ini;
std::string file = GetJString(env, jFile);