Last active
October 26, 2015 02:34
-
-
Save shts/b10ff515d50b9533dffe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.shts.android.nogirepo; | |
public class AppUser extends Person { | |
AppUser(String id, String url, String name) { | |
super(Type.APP_USER, id, url, name); | |
} | |
public static List<AppUser> findByIds(List<String> idList) { | |
// ParseUser | |
ParseQuery<ParseObject> query = ParseQuery.getQuery("AppUser"); | |
query.whereContainedIn("social_id", idList); | |
List<ParseUser> users = query.findInBackground(); | |
return users; | |
} | |
public static void findByIds(List<String> idList, FindCallback<AppUser> callback) { | |
// ParseUser | |
ParseQuery<ParseObject> query = ParseQuery.getQuery("AppUser"); | |
query.whereContainedIn("social_id", idList); | |
query.findInBackground(callback); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.shts.android.nogirepo; | |
import jp.shts.android.nogirepo.Person.Type; | |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import android.content.ContentValues; | |
import android.util.Pair; | |
/** | |
* | |
{ | |
"talk": [ | |
{ | |
"person": { | |
"type": "member", | |
"_id": "a", | |
"name": "a", | |
"url": "a" | |
}, | |
"say": "hello" | |
}, | |
{ | |
"person": { | |
"type": "app_user", | |
"_id": "a", | |
"name": "a", | |
"url": "a" | |
}, | |
"say": "hello" | |
}, | |
{ | |
"person": { | |
"type": "member", | |
"_id": "a", | |
"name": "a", | |
"url": "a" | |
}, | |
"say": "hello" | |
} | |
] | |
} | |
* | |
*/ | |
public class Talk extends PairList<Person, String> { | |
public static Talk createFrom(JSONObject jsonObject) { | |
Talk talk = new Talk(); | |
if (jsonObject == null) { | |
// return Empty Object | |
return talk; | |
} | |
try { | |
JSONArray rootObject = (JSONArray) jsonObject.get("talk"); | |
final int N = rootObject.length(); | |
for (int i = 0; i < N; i++) { | |
JSONObject object = (JSONObject) rootObject.get(i); | |
JSONObject personObject = object.getJSONObject("person"); | |
String typeString = personObject.getString("type"); | |
String _id = personObject.getString("_id"); | |
String name = personObject.getString("name"); | |
String url = personObject.getString("url"); | |
String say = object.getString("say"); | |
Type personType = Type.from(typeString); | |
if (personType == Type.APP_USER) { | |
talk.add(new AppUser(_id, name, url), say); | |
} else if (personType == Type.MEMBER) { | |
talk.add(new Member(_id, name, url), say); | |
} | |
} | |
} catch (JSONException e) { | |
// | |
} | |
return talk; | |
} | |
public JSONArray toJSONArray() { | |
JSONArray talk = new JSONArray(); | |
try { | |
for (Pair<Person, String> pair : this) { | |
JSONObject jsonObject = new JSONObject(); | |
JSONObject person = new JSONObject(); | |
person.put("_id", pair.first.id); | |
person.put("name", pair.first.name); | |
person.put("url", pair.first.url); | |
jsonObject.put("person", person); | |
jsonObject.put("say", pair.second); | |
talk.put(jsonObject); | |
} | |
return talk; | |
} catch (JSONException e) { | |
} | |
return talk; | |
} | |
public void load(String id) { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TwitterApiClient { | |
private TwitterApiClient() {} | |
public abstract class TwitterApiResponseHandler { | |
private Handler mHandler; | |
public TwitterApiResponseHandler() {} | |
public TwitterApiResponseHandler(Looper looper) { | |
mHandler = new Handler(looper); | |
} | |
public void notify(final String responseBody) { | |
if (mHandler != null) { | |
mHandler.post(new Runnable() { | |
@Override | |
public void run() { | |
onFinish(responseBody); | |
} | |
}); | |
} else { | |
onFinish(responseBody); | |
} | |
} | |
public abstract void onFinish(String responseBody); | |
} | |
private static final HandlerThread WORKER_THREAD = new HandlerThread("TwitterApiClient-Thread"); | |
private static final Handler WORKER; | |
static { | |
WORKER_THREAD.start(); | |
WORKER = new Handler(WORKER_THREAD.getLooper()); | |
} | |
public abstract class GetLinkedTwitterFriendsResponseHandler extends TwitterApiResponseHandler { | |
public GetLinkedTwitterFriendsResponseHandler() { | |
super(); | |
} | |
public GetLinkedTwitterFriendsResponseHandler(Looper looper) { | |
super(looper); | |
} | |
@Override | |
public void onFinish(String responseBody) { | |
TwitterFriends friends = TwitterFriends.from(responseBody); | |
// Get linked friends from twitter friends. | |
List<AppUser> appUserList = AppUser.findByIds(friends.getIdList()); | |
handler.onFinish(appUserList); | |
} | |
public abstract void onFinish(List<AppUser> appUserList); | |
} | |
public static void getAllLinkedTwitterFriend(final GetLinkedTwitterFriendsResponseHandler handler) { | |
get(handler); | |
} | |
private static void get(final TwitterApiResponseHandler handler) { | |
WORKER.post(new Runnable() { | |
@Override | |
public void run() { | |
final String responseBody = syncGetAllFriends(); | |
handler.onFinish(appUserList); | |
} | |
}); | |
} | |
private static String syncGetAllFriends() { | |
String twitterId = ParseTwitterUtils.getTwitter().getId(); | |
String url = "https://api.twitter.com/1.1/friends/ids.json?user_id=" + twitterId; | |
HttpGet verifyGet = new HttpGet(url); | |
ParseTwitterUtils.getTwitter().signRequest(verifyGet); | |
return execute(verifyGet); | |
} | |
private String execute(HttpGet verifyGet) { | |
HttpClient client = new DefaultHttpClient(); | |
try { | |
return client.execute(verifyGet, new ResponseHandler<String>() { | |
@Override | |
public String handleResponse(HttpResponse response) | |
throws ClientProtocolException, IOException { | |
// response.getStatusLine().getStatusCode()でレスポンスコードを判定する。 | |
// 正常に通信できた場合、HttpStatus.SC_OK(HTTP 200)となる。 | |
switch (response.getStatusLine().getStatusCode()) { | |
case HttpStatus.SC_OK: | |
// レスポンスデータを文字列として取得する。 | |
// byte[]として読み出したいときはEntityUtils.toByteArray()を使う。 | |
return EntityUtils.toString(response.getEntity(), "UTF-8"); | |
case HttpStatus.SC_NOT_FOUND: | |
throw new RuntimeException("データないよ!"); //FIXME | |
default: | |
throw new RuntimeException("なんか通信エラーでた"); //FIXME | |
} | |
} | |
}); | |
} catch (ClientProtocolException e) { | |
throw new RuntimeException(e); //FIXME | |
} catch (IOException e) { | |
throw new RuntimeException(e); //FIXME | |
} finally { | |
// ここではfinallyでshutdown()しているが、HttpClientを使い回す場合は、 | |
// 適切なところで行うこと。当然だがshutdown()したインスタンスは通信できなくなる。 | |
httpClient.getConnectionManager().shutdown(); | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TwitterFriend { | |
// id | |
public String id_str; | |
public in id; | |
// name | |
public String name; | |
public String screen_name; | |
// image | |
public String profile_image_url; | |
public String profile_image_url_https; | |
// color | |
public String profile_sidebar_fill_color; | |
public String profile_sidebar_border_color; | |
public String profile_link_color; | |
public String profile_text_color; | |
public String profile_background_color; | |
public static Friend from(JSONObject jsonObject) { | |
Friend friend = new Friend(); | |
try { | |
friend.id_str = jsonObject.getString("id_str"); | |
friend.id = jsonObject.getInt("id"); | |
friend.name = jsonObject.getString("name"); | |
friend.screen_name = jsonObject.getString("screen_name"); | |
friend.profile_image_url = jsonObject.getString("profile_image_url"); | |
friend.profile_image_url_https = jsonObject.getString("profile_image_url_https"); | |
friend.profile_sidebar_fill_color = jsonObject.getString("profile_sidebar_fill_color"); | |
friend.profile_sidebar_border_color = jsonObject.getString("profile_sidebar_border_color"); | |
friend.profile_link_color = jsonObject.getString("profile_link_color"); | |
friend.profile_text_color = jsonObject.getString("profile_text_color"); | |
friend.profile_background_color = jsonObject.getString("profile_background_color"); | |
} catch (JSONException e) { | |
// | |
} | |
return friend; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TwitterFriends extends ArrayList<TwitterFriend> { | |
private TwitterFriends() {} | |
public static TwitterFriends from(String jsonString) { | |
if (TextUtils.isEmpty(jsonString)) { | |
return new TwitterFriends(); | |
} | |
JSONArray rootObject = new JSONArray(jsonString); | |
final int N = rootObject.size(); | |
for (int i = 0; i < N; i++) { | |
add(TwitterFriend.from(rootObject.get(i))); | |
} | |
} | |
public ArrayList<String> getIdList() { | |
ArrayList<String> list = new ArrayList<String>(); | |
for (TwitterFriend friend : this) { | |
list.add(friend.id_str); | |
} | |
return list; | |
} | |
} |
Fab policy
Fab押下時にFab上部に表示するminiボタンは3~6まで。
ex)自分、メンバー、メンバーを追加
Lib
- RapidFloatingActionButton
https://android-arsenal.com/details/1/1781
-> アイコンをカスタムできない。依存ライブラリが多い - fab-transformation
https://github.com/konifar/fab-transformation
-> うすくてシンプル。Android 2.3+ - https://github.com/futuresimple/android-floating-action-button
-> inboxっぽい実装ができそう。minSdkVersion=14
Color
primary
673AB7
primary-dark
512DA8
accent
FF4081
accent-dark
F50057
http://developer.android.com/intl/ja/training/material/theme.html#ColorPalette
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parse
参考になりそうな資料
Query
http://murayama.hatenablog.com/entry/2013/11/30/093741
Relational Data
http://murayama.hatenablog.com/entry/2013/11/28/080444
Parse - Relations
http://murayama.hatenablog.com/entry/2014/01/21/215738
Parseを使ってソーシャルログイン&POSTまでやってみる
http://qiita.com/masahide318/items/ccc279a77f2d9de2bcae
ParseSDK のトラップを集めたページ
http://qiita.com/KeithYokoma/items/1e1c2f5813299ce39bb4
JavaDoc
https://parse.com/docs/android/api/com/parse/ParseUser.html
参考になりそうな実装
ParseTwitterUtils
経由のAPI利用方法についてSample Code
https://github.com/teamOSC/LearnHut_android/blob/d4ed00740d6a45e8c9b80ba6f63bcc0ff3bd1a18/app/src/main/java/in/tosc/studddin/externalapi/TwitterApi.java
Layout
吹き出し
https://github.com/lguipeng/BubbleView
ListView並べ替え
Simple:
http://shogogg.hatenablog.jp/entry/20110118/1295326773
Rich:
http://d.hatena.ne.jp/tomorrowkey/20100720/1279597322
ListViewスワイプで削除
Androidで横スワイプで削除できるリストビューの作り方(ライブラリ使用)
http://qiita.com/kassy_kz/items/4467bc58384bb73cee85
SwipeMenuListView:
https://android-arsenal.com/details/1/912
AndroidSwipeLayout:
https://github.com/daimajia/AndroidSwipeLayout
Inbox Style Swipe ListView:
http://www.jayrambhia.com/blog/swipe-listview/
Android-SwipeToDismiss:
https://github.com/romannurik/android-swipetodismiss
ListViewAnimations:
https://github.com/nhaarman/ListViewAnimations
Swipe to delete with ListViewAnimations:
http://www.apptrench.com/swipe-to-delete-with-listviewanimations/
SwipeListView:
https://android-arsenal.com/details/1/255
ListView並べ替え&&スワイプで削除
ListViewAnimations:
http://nhaarman.github.io/ListViewAnimations/#getting-started
実装優先度
レポート作成・保存(LOCAL)機能
Twitterログイン
Twitterでフォローしているメンバーから本サービスを利用している人を探す。
レポート作成・保存(CLOUD)機能
like,unlikeカウンタを表示する
通知機能
リプライされた、お気に入りされた、フォローされたを通知する
Tag機能
SimpleNote用
MaterialLetterIcon
https://android-arsenal.com/details/1/2633
URL
http://dogrun-navi.com/
Design
https://dribbble.com/shots/2290815-Shiba-Inu