Log variables
This commit is contained in:
parent
3209f036d0
commit
42ca1a016c
|
@ -6,12 +6,23 @@ import android.widget.Toast;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.blankie.unshortify.R;
|
import com.blankie.unshortify.R;
|
||||||
|
|
||||||
public class ShareActivity extends Activity {
|
public class ShareActivity extends Activity {
|
||||||
public static final String TAG = "unshortify";
|
public static final String TAG = "unshortify";
|
||||||
|
|
||||||
|
private void logVariable(final String name, final String value) {
|
||||||
|
String msg = name + " = ";
|
||||||
|
if (value != null) {
|
||||||
|
msg += "[" + value + "]";
|
||||||
|
} else {
|
||||||
|
msg += "null";
|
||||||
|
}
|
||||||
|
Log.d(TAG, msg);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -19,6 +30,7 @@ public class ShareActivity extends Activity {
|
||||||
try {
|
try {
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
final String urlString = intent.getStringExtra(Intent.EXTRA_TEXT);
|
final String urlString = intent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
logVariable("urlString", urlString);
|
||||||
if (urlString == null || urlString == "") {
|
if (urlString == null || urlString == "") {
|
||||||
Toast.makeText(getApplicationContext(), R.string.empty_url,
|
Toast.makeText(getApplicationContext(), R.string.empty_url,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
@ -26,6 +38,7 @@ public class ShareActivity extends Activity {
|
||||||
}
|
}
|
||||||
|
|
||||||
final Uri urlParsed = Uri.parse(urlString);
|
final Uri urlParsed = Uri.parse(urlString);
|
||||||
|
logVariable("scheme", urlParsed.getScheme());
|
||||||
if (urlParsed.getScheme() != "http" && urlParsed.getScheme() != "https" &&
|
if (urlParsed.getScheme() != "http" && urlParsed.getScheme() != "https" &&
|
||||||
urlParsed.getScheme() != "") {
|
urlParsed.getScheme() != "") {
|
||||||
Toast.makeText(getApplicationContext(), R.string.unknown_scheme,
|
Toast.makeText(getApplicationContext(), R.string.unknown_scheme,
|
||||||
|
@ -33,6 +46,7 @@ public class ShareActivity extends Activity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logVariable("host", urlParsed.getHost());
|
||||||
if (urlParsed.getHost() == null || (urlParsed.getHost() != "youtube.com" &&
|
if (urlParsed.getHost() == null || (urlParsed.getHost() != "youtube.com" &&
|
||||||
urlParsed.getHost().endsWith(".youtube.com"))) {
|
urlParsed.getHost().endsWith(".youtube.com"))) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.non_youtube_url,
|
Toast.makeText(getApplicationContext(), R.string.non_youtube_url,
|
||||||
|
@ -40,6 +54,7 @@ public class ShareActivity extends Activity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logVariable("path", urlParsed.getPath());
|
||||||
if (urlParsed.getPath() == null) {
|
if (urlParsed.getPath() == null) {
|
||||||
Toast.makeText(getApplicationContext(), R.string.null_path,
|
Toast.makeText(getApplicationContext(), R.string.null_path,
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
|
|
Loading…
Reference in New Issue