@@ -0,0 +1,22 @@
package com.iyuelbs.utils;

import android.content.Context;

import com.android.volley.Response;
import com.android.volley.VolleyError;

/**
* Created by Bob Peng on 2015/1/31.
*/
public class BaseErrorListener implements Response.ErrorListener {
private Context mContext;

public BaseErrorListener(Context context) {
mContext = context;
}

@Override
public void onErrorResponse(VolleyError error) {
ViewUtils.showToast(mContext, error.getMessage());
}
}
@@ -1,6 +1,13 @@
package com.iyuelbs.utils;

import android.os.Bundle;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.Calendar;
import java.util.Iterator;
import java.util.TimeZone;

/**
@@ -10,4 +17,52 @@ public class Utils {
public static long getTimestamp() {
return Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTimeInMillis() / 1000l;
}

public static Bundle toBundle(JSONObject json) {
Iterator<String> iterator = json.keys();
Bundle bundle = new Bundle();
try {
while (iterator.hasNext()) {
String key = iterator.next();
bundle.putString(key, json.getString(key));
Log.e("xifan", "key=" + key + " value=" + json.getString(key));
}
} catch (JSONException e) {
e.printStackTrace();
}

return bundle;
}
//
// public static Bundle parseUrl(String url) {
// try {
// URL u = new URL(url);
// Bundle b = decodeUrl(u.getQuery());
// b.putAll(decodeUrl(u.getRef()));
// return b;
// } catch (MalformedURLException e) {
// return new Bundle();
// }
// }
//
// public static Bundle decodeUrl(String s) {
// Bundle params = new Bundle();
// if (TextUtils.isEmpty(s)) {
// return params;
// }
//
// String array[] = s.split("&");
// for (String parameter : array) {
// if (TextUtils.isEmpty(parameter)) {
// continue;
// }
// String v[] = parameter.split("=");
// if (v.length < 2) {
// continue;
// }
// params.putString(URLDecoder.decode(v[0]), URLDecoder.decode(v[1]));
// }
//
// return params;
// }
}
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<WebView
android:id="@+id/auth_webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

<ProgressBar
android:id="@+id/auth_progress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:max="100"
android:progressDrawable="@color/pink"/>
</FrameLayout>
@@ -43,4 +43,21 @@
android:layout_height="wrap_content"
android:text="@string/btn_login"/>

<Button
android:id="@+id/login_weibo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="微博登陆"/>

<Button
android:id="@+id/login_qq"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="QQ登陆"/>
<Button
android:id="@+id/login_logoff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注销"/>

</LinearLayout>