ã¯ããã«
ãœãŒã·ã£ã«ãããã¯ãŒã¯ãè±å¯ã«ããã«ãããããããéå»æ°å¹Žã«ããã£ãŠã åã«yo ã snapchat ã secretãªã©ãäžé£ã®æ°ãããªãªãžãã«ã®çãããœãŒã·ã£ã«ã¢ããªã±ãŒã·ã§ã³ãç»å ŽããŸãããåäžã®æ©èœã«éå®ããããžã£ã¹ããšãŒã¢ããªã±ãŒã·ã§ã³ã®æåç§ã®å人ãšç§ã¯ãAndroidã§å¥ã®ãœãŒã·ã£ã«ãããã¯ãŒã¯ãäœæããããšã決å®ããŸããã ç§ãã¡ã®ç®æšã¯ãã»ãšãã©ã®ãã®ãããªã¢ããªã±ãŒã·ã§ã³ã«å ±éããã¿ã¹ã¯ã®ç¯å²ãæŠèª¬ãããããã«è§£æ±ºçãææ¡ãã誰ããæ¥åžžçãªåé¡ã解決ããæéãç¡é§ã«ããããšãªãç¬èªã®ãªãªãžãã«ãäœæã§ããã¹ã±ã«ãã³ãæºåããããšã§ããã githubã§ã®äœæ¥ã®çµæãããã«èŠãããšãã§ããŸã - ã¬ãŒã«äžã®rubyäžã® Androidã¯ã©ã€ã¢ã³ãããã³ãµãŒã㌠ã
å 容
ã³ã³ã»ãããšæ©èœ
ã€ã³ã¿ãŒãã§ãŒã¹
ããé«éãªåçã®ã¢ããããŒã
ãã¬ã³ãã«ãŠã³ã
ãããã¯ãŒã¯ãªã¯ãšã¹ã
ãã°ã€ã³
ããŒã¿ããŒã¹é£çµ¡å ãç»åçšã®SQLite
ç¶ã
ã³ã³ã»ãããšæ©èœ
ãŸããæ°ãããµãŒãã¹ã®æŠå¿µã決å®ããã¢ãã«ãéžæããŸãã-ãã€ããªããinstagramãšwhatsappã§ãã instagramããäž»ãªãŠãŒã¹ã±ãŒã¹-ã³ã¡ã³ãããããïŒãä»ããŠå人ã®ãã£ãŒãã«åçãã¢ããããŒãããŸã ãããŠVotsapãããå人ã®ã°ã©ããæŽçããååã¯ãèªåã¢ãŒãã§å人ã®é»è©±çªå·ã䜿çšããŠããŒãããã¯ã䜿çšããããšã§ãã
éžæããã¢ãã«ã®æ©èœ
éžæãããã°ã©ãã¢ãã«ã¯ãå¹³åãããã¯ãŒã¯æé·çãæå³ããŸãã åæ°èŠãŠãŒã¶ãŒã¯ãããŒãããã¯ããã¢ããªã±ãŒã·ã§ã³ã«æ倧æ°å/æ°çŸäººãæç»ã§ããŸãã äžæ¹ããã®ã¢ãããŒãã§ã¯ãéçºã®åæ段éã§ã³ã³ãã³ãã®ã¢ãã¬ãŒããšãã£ã«ã¿ãªã³ã°ãäžèŠã«ãªããŸãã ã³ã³ãã³ãã®å¯çšæ§ã¯ããŠãŒã¶ãŒã®å人çãªé£çµ¡å
ã«ãã£ãŠæ±ºå®ããã倧éã®ã¹ãã ã¡ãŒã«ããã®ä»ã®æ害ãªçŸè±¡ãé²ããŸãã ãã®çµæãç°¡åãªãµãŒãã¹ãæäŸãããå人ãšããã«äœ¿çšã§ããæè¡çããã³çµç¹çãªèŠ³ç¹ããéçšãµããŒãã«å€é¡ã®è²»çšãå¿
èŠãšããŸããã
次ã«ãã¢ããªã±ãŒã·ã§ã³ã®æå°æ©èœã®æŠèŠã説æããŸããã
- åçãã¢ããããŒãããŠã®ã£ã©ãªãŒã§èŠã
- ããŒãããã¯ããŒã¹ã®åéãªã¹ã管ç
- åéãã¢ããããŒãããåçãã£ãŒã
ã€ã³ã¿ãŒãã§ãŒã¹
åºæ¬çãªæ©èœã®ç¯å²ãæŠèª¬ããåŸãã€ã³ã¿ãŒãã§ã€ã¹ã®èšèšã«ç§»ããŸããã åé¢æ°ã¯å¥ã ã®ãã©ã°ã¡ã³ãã«ããŸãé 眮ããããããã®äœ¿çšã®çãã確çã¯ã ViewPagerã䜿çšããæ°Žå¹³ã¹ã¯ã€ããã©ã³ãžã·ã§ã³ã®äœ¿çšã瀺åããŸãïŒã¹ã¯ã€ãã®ãã¥ãŒããªã¢ã«ãšViewPager ãã¥ãŒããªã¢ã«1 ãã¥ãŒããªã¢ã«2 ïŒã æåã®æ®µéã§ã次ã®é·ç§»å³ãååŸããŸããã
å³ 1.å€æãã£ãŒã
åãã©ã°ã¡ã³ãããã詳现ã«æ€èšããŸãã
ã³ã³ã¿ã¯ãã·ãŒã
å³ 2.ã³ã³ã¿ã¯ãã·ãŒã-ã¯ã€ã€ãã¬ãŒã ãšã¹ã¯ãªãŒã³ã·ã§ãã
é£çµ¡å ãªã¹ãã«ã¯ããµãŒãã¹ã«ç»é²ãããŠããããŒãããã¯ã®å人ã®ãªã¹ãã衚瀺ããã賌èªããããšãã§ããã¯ãªãã¯ãããšè©³çŽ°ãªãŠãŒã¶ãŒãããã¡ã€ã«ãéããŸãã éåžžã®ListView ïŒ ãã¥ãŒããªã¢ã« ïŒã«ãã£ãŠå®è£ ãããŸãã
ã®ã£ã©ãªãŒ
å³ 3.ã®ã£ã©ãªãŒ-ã¯ã€ã€ãŒãã¬ãŒã ãšã¹ã¯ãªãŒã³ã·ã§ãã
ã®ã£ã©ãªãŒã«ã¯ããµãŒããŒã«ã¢ããããŒããããããŒã«ã«ããã³ãŠãŒã¶ãŒã®åçãã¿ã€ãã«ã«ç°¡åãªèª¬æãšãšãã«è¡šç€ºãããŸãã
ãªããªã ã¿ã€ãã«ãšã¢ã¹ãã¯ãæ¯ãèæ ®ããåçã®ãµã€ãºã¯ç°ãªãå Žåãããããã Etsy AndroidStaggeredGridã®é察称GridViewã䜿çšããããšã«ããŸããã ãã®å Žåã®ãããã³ã°äœçœ®æ±ºãã¢ã«ãŽãªãºã ã«ã¯ç¹å¥ãªã¢ãããŒããå¿ èŠã§ããç¹ã«ã AndroidStaggeredGridã¯ImageViewã®ä»£ããã«æå®ã®æ¯çã§DynamicHeightImageViewã䜿çšããŸã ã ãã®çµæãããªããããã§ã¹ã ãŒãºã«ã¹ã¯ããŒã«å¯èœãªã¿ã€ã«ã®ã£ã©ãªãŒãã§ããŸããã
ãªãã³
ãã£ãŒãã«ã¯ããŠãŒã¶ãŒããã©ããŒããŠããå人ãã¢ããããŒãããåçã衚瀺ãããŸãã ããã§ã¯ãéåžžã®ListViewã䜿çšããŸããã ååçã¯ç»é¢ã®å€§éšåãå ãããããèŠãããããºãŒã ãç»é¢ã®å¹ å šäœã«åºããããšãã§ããŸãã ç»åãã¯ãªãã¯ãããšãã³ã¡ã³ãä»ãã®åçã®è©³çŽ°ãªèª¬æãéããŸãã
å³ 4.ãªãã³-ã¯ã€ã€ãã¬ãŒã ãšã¹ã¯ãªãŒã³ã·ã§ãã
åçã®è©³çŽ°ãªèª¬æ
åçã®è©³çŽ°ãªèª¬æã«ã¯ãéžæããç»åã®ã¡ã¿ããŒã¿ïŒèè åã説æããããã®æ°ãªã©ïŒãšã³ã¡ã³ãã®ãªã¹ããå«ãŸããŸãã
å³ 5.åçã®èª¬æ-ã¯ã€ã€ãã¬ãŒã ãšã¹ã¯ãªãŒã³ã·ã§ãã
ãŠãŒã¶ãŒãããã¡ã€ã«
ãŠãŒã¶ãŒãããã¡ã€ã«ã«ã¯ããŠãŒã¶ãŒã¡ã¿ããŒã¿ãšã¢ããããŒãããããŠãŒã¶ãŒåçã®ã®ã£ã©ãªãŒãå«ãŸããŸãã
å³ 6.ãŠãŒã¶ãŒãããã¡ã€ã«-ã¯ã€ã€ãã¬ãŒã ãšã¹ã¯ãªãŒã³ã·ã§ãã
ããé«éãªåçã®ã¢ããããŒã
L1 / L2ãã£ãã·ã¥
åçã®ã¢ããããŒãã¯éèŠã§ãããéåžžã«ãªãœãŒã¹ãæ¶è²»ããããã»ã¹ã§ãã åçã¯ãããã€ã¹ã®ããŒã«ã«ã®ã£ã©ãªãŒãšãªã¢ãŒãã¹ãã¬ãŒãžã®äž¡æ¹ããããŠã³ããŒããããŸãã ããŠã³ããŒãé床ã¯ãã®ã£ã©ãªãŒã®ã¹ã¯ããŒã«ã®ã¹ã ãŒãºããšã€ã³ã¿ãŒãã§ãŒã¹ã®äžè¬çãªå©äŸ¿æ§ã«åœ±é¿ãäžãããããRAMã®L1ãã£ãã·ã¥ãšããã€ã¹ã®ãã£ã¹ã¯ã¡ãã£ã¢ã®L2ãã£ãã·ã¥ã®2ã¬ãã«ãã£ãã·ã¥ã䜿çšããããšã«ããŸããã
ãã£ã¹ã¯L2ãã£ãã·ã¥ãšããŠã Jake Whartonãã人æ°ã®ãããã©ã°ã€ã³ãéžæããŸãããããã¯ãžã£ãŒããªã³ã°ããµããŒããã Android SDKã®æšæºDiskLruCacheã«å¯Ÿãã䟿å©ãªã©ãããŒãæäŸããŸã ã L1ãã£ãã·ã¥ã¯ãæšæºã®Android LruCacheã«ãã£ãŠå®è£ ãããŸã ïŒ com.freecoders.photobook.utils.DiskLruBitmapCacheããã³com.freecoders.photobook.utils.MemoryLruCacheãåç §ïŒã
ããã¢ã¯ãã£ããªã¹ã±ãŒãªã³ã°
ãã¥ãŒã¹ãã£ãŒãã®å Žåããã£ãŒããæ¢ã«ããŠã³ããŒããããŠãããåŒãç¶ããªã¢ãŒãã¹ãã¬ãŒãžããåçãããŠã³ããŒããããŠããå¯èœæ§ããããŸãã 次ã«ããŠãŒã¶ãŒãæ¢ã«ãªã¹ããäžã«ã¹ã¯ããŒã«ããŠããå Žåãã¹ã¯ããŒã«æã«ããŒããå®äºãããšã é®çå¹æãåŸãããŸãã ãããåé¿ããããã«ãããŒãã®ãã£ã¹ãã¬ã€ã®ããã¢ã¯ãã£ããªã¹ã±ãŒãªã³ã°ãé©çšããŸããã åçã®ãã¬ãŒã ãµã€ãºã¯ã¢ã¹ãã¯ãæ¯ã«åºã¥ããŠèšç®ãããåçããµãŒããŒããããŠã³ããŒããããåã«èšå®ãããŸãã ãããã£ãŠãæ°ããåçãããŒãããåŸãListViewå ã®ã¢ã€ãã ã®äœçœ®ã¯å€ãããŸããã
ã³ãŒã1. DynamicHeightImageViewã®ããã¢ã¯ãã£ãã¹ã±ãŒãªã³ã°ã®äŸ
ã¯ã©ã¹FeedAdapter
public View getView(int position, View convertView, ViewGroup parent) { ... holder.imgView.setHeightRatio(feedEntry.image.ratio); holder.imgView.setTag(pos); mImageLoader.get(feedEntry.image.url_medium, new ImageListener(pos, holder.imgView, null)); ... }
ããŠã³ãµã³ããªã³ã°
ããã«ãAndroidã«ã¯ãç»é¢ã«è¡šç€ºãããåçã®æ倧ãµã€ãºãšè§£å床ã«å¶éããããŸãã ããã¯ãã¡ã¢ãªãªãŒããŒãããŒãé²ãããã§ãã ãããã£ãŠããããããããããŠã³ããŒãããåã«ã ããŠã³ãµã³ããªã³ã°ãå®è¡ããå¿ èŠããããŸãã
ã³ãŒã2.ç»åã®ããŠã³ãµã³ããªã³ã°ã®äŸ
ã¯ã©ã¹ImageUtils
public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { final int height = options.outHeight; final int width = options.outWidth; int inSampleSize = 1; if (height > reqHeight || width > reqWidth) { final int halfHeight = height / 2; final int halfWidth = width / 2; while (((halfHeight / inSampleSize) > reqHeight) || ((halfWidth / inSampleSize) > reqWidth)) { inSampleSize *= 2; } } return inSampleSize; } public static Bitmap decodeSampledBitmap(String imgPath, int reqWidth, int reqHeight) { final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(imgPath, options); options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(imgPath, options); }
ãµã ãã€ã«
ãŸããã¡ãã£ã¢ã¹ãã£ããŒããã¹ãŠã®åçãåŠçã§ããå Žåã¯ãããã€ã¹ã®ã¡ã¢ãªã«ãããã®ãµã ãã€ã«ãæ¢ã«äœæã§ããŸãã ãã®ã«ãŒã«ã¯åžžã«åœãŠã¯ãŸãããã§ã¯ãããŸãããããµã ãã€ã«ãããå ŽåãããŒãããã»ã¹ãå€§å¹ ã«é«éåãããããŠã³ãµã³ããªã³ã°ãåé¿ãããŸãã
ã³ãŒã3. MediaStoreãããµã ãã€ã«ãããŠã³ããŒãããäŸ
ã¯ã©ã¹ImagesDataSource
public String getThumbURI(String strMediaStoreID) { ContentResolver cr = mContext.getContentResolver(); String strThumbUri = ""; Cursor cursorThumb = cr.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, new String[]{MediaStore.Images.Thumbnails.DATA}, MediaStore.Images.Thumbnails.IMAGE_ID + "= ?", new String[]{strMediaStoreID}, null); if( cursorThumb != null && cursorThumb.getCount() > 0 ) { cursorThumb.moveToFirst(); strThumbUri = cursorThumb.getString( cursorThumb.getColumnIndex( MediaStore.Images.Thumbnails.DATA )); } cursorThumb.close(); return strThumbUri; }
ãã¬ã³ãã«ãŠã³ã
ã€ã³ã¿ãŒãã§ã€ã¹ãšãµãŒãã¹ã®ããžãã¯ãå®çŸ©ãã次ã®ã¹ãããã¯ããã¬ã³ãã°ã©ããããªã«ããŠã³ããããšã§ããã å人ã®ååïŒVKontakteãªã©ïŒãšè³Œèªè ã®ååïŒTwitterãªã©ïŒã®2ã€ã®ã¢ãããŒããæ€èšããŸããã å人ã®ååã¯ãã®ã£ã©ãªãŒãšå人ãããã£ãŒã«ã«ã¢ã¯ã»ã¹ããããã®çžäºã®åæãæå³ããå察åŽããã®ç¥ãåãã®ç¢ºèªãå¿ èŠãšããŸãã å å ¥è ã®å Žåãå察åŽãã確èªãèŠæ±ããå¿ èŠã¯ãªããååœäºè ãåçããŒãã®å å¡«å ãåå¥ã«æ±ºå®ã§ããããã«ããŸãã
ãã®éžæã¯ããµãŒããŒäžã®ãªã¬ãŒã·ã§ãã«ããŒã¿ããŒã¹ã®æååïŒãµãã¹ã¯ã©ã€ããŒIDãäœæè IDïŒãšããŠå®è£ ãããæåã°ã©ããæå³ããŸãã
ãããã¯ãŒã¯ãªã¯ãšã¹ã
ãã¹ãŠã®ãããã¯ãŒã¯èŠæ±ã¯éåæã§å®è¡ãããæäœã®çµæã¯ã³ãŒã«ããã¯ã€ã³ã¿ãŒãã§ã€ã¹ã䜿çšããŠèŠæ±ã¢ãžã¥ãŒã«ã«è»¢éãããŸãã 2013幎ãGoogleã¯Apache HTTPClientã®ä»£ãããšããŠç¬èªã®Volleyãã©ã°ã€ã³ãå°å ¥ããŸããã ãã®å©ç¹ã¯ã èŠæ±ãã¥ãŒ ã åªå é äœä»ã ã æååããã³jsonèŠæ±ã®æšæºã©ãã㌠ã ããŒãã¢ã©ã€ã ã倱ææã«åéãªã©ã®ãµããŒãã§ããã»ãšãã©ã®ãããã¯ãŒã¯èŠæ±ã®åºç€ãšããŠäœ¿çšããããšã«ããŸããã
ãã¬ãŒã§å¥œãã§ã¯ãªãã£ããã®
ä»åŸãVolleyã¯HTTPClientãšæ¯èŒããŠãããã¯ãŒã¯ã€ã³ã¿ãŒãã§ãŒã¹ã®éçºãæ¬åœã«ç°¡çŽ åãããšèšããŸãããéçºæç¹ã§ã¯ãVolleyããã®Stringããã³Jsonãªã¯ãšã¹ãã®æšæºã©ãããŒã¯æªå å·¥ã§ãããããããå°ãæžãæããŸãïŒcom.freecoders.photobook.network.MultiPartRequestããã³com.freecoders.photobook.network.StringRequestãåç
§ïŒ
ã³ãŒã4.ãããã¯ãŒã¯èŠæ±ã®äŸïŒãŠãŒã¶ãŒãããã¡ã€ã«èŠæ±ïŒ
ã¯ã©ã¹ServerInterface
public static final void getUserProfileRequest (Context context, String[] userIds, final Response.Listener<HashMap<String, UserProfile>> responseListener, final Response.ErrorListener errorListener) { HashMap<String, String> headers = makeHTTPHeaders(); String strIdHeader = userIds.length > 0 ? userIds[0] : ""; for (int i = 1; i < userIds.length; i++) strIdHeader = strIdHeader + "," + userIds[i]; headers.put(Constants.KEY_ID, strIdHeader); Log.d(LOG_TAG, "Get user profile request"); StringRequest request = new StringRequest(Request.Method.GET, Constants.SERVER_URL + Constants.SERVER_PATH_USER, "", headers, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d(LOG_TAG, response); Type type = new TypeToken<ServerResponse <HashMap<String, UserProfile>>>(){}.getType(); try { ServerResponse<HashMap<String, UserProfile>> res = gson.fromJson(response, type); if (res != null && res.isSuccess() && res.data != null && responseListener != null) responseListener.onResponse(res.data); else if (responseListener != null) responseListener.onResponse(new HashMap<String, UserProfile>()); } catch (Exception e) { if (responseListener != null) responseListener.onResponse(new HashMap<String, UserProfile>()); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { if ((error != null) && (error.networkResponse != null) && (error.networkResponse.data != null)) Log.d(LOG_TAG, "Error: " + new String(error.networkResponse.data)); if (errorListener != null) errorListener.onErrorResponse(error); } } ); VolleySingleton.getInstance(context).addToRequestQueue(request); }
ã³ãŒã5. VolleySingleton
ã¯ã©ã¹VolleySingleton
public class VolleySingleton { ... public <T> void addToRequestQueue(Request<T> req) { int socketTimeout = 90000; RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); req.setRetryPolicy(policy); getRequestQueue().add(req); } ... }
ãã°ã€ã³
æ¿èªã®ããã«ã ãããªãã¯IDãšãã©ã€ããŒãIDã®ãã¢ã䜿çšããããšã«ããŸããã ç»é²ãããšããã®ãã¢ã¯ã¯ã©ã€ã¢ã³ãã«éä¿¡ããããã©ã€ããŒãIDã¯ãã®ãŠãŒã¶ãŒã®ã¿ã䜿çšã§ãããµãŒããŒãžã®åãªã¯ãšã¹ããšãšãã«HTTPããããŒã§éä¿¡ãããŸãã ãŸãããããªãã¯IDã¯ãã¹ãŠã®ãŠãŒã¶ãŒãã¢ã¯ã»ã¹å¯èœã§ãããä»ã®ã¯ã©ã€ã¢ã³ããå人ãšããŠè¿œå ããããšãèŠæ±ãããšãããŸãã¯ãããã¡ã€ã«ã衚瀺ãããšãã«äœ¿çšãããŸãã
ããŒã¿ããŒã¹é£çµ¡å ãç»åçšã®SQLite
ããŒã«ã«ã¯ã©ã€ã¢ã³ãããŒã¿ããŒã¹ã«ã¯ããµãŒããŒã®è² è·ã軜æžããããã«å¿ èŠãªæå°éã®æ å ±ãå«ãŸããŠããŸãã
- åéãªã¹ã
- ã¢ããããŒããããåçã®ãªã¹ã
ãµãŒãã¹ã«ç»é²ãããŠããã¢ãã¬ã¹åž³ã®å人ã®ãªã¹ããã¡ã¿ããŒã¿ïŒã¢ãã¿ãŒãååãªã©ïŒã¯ãã¢ããªã±ãŒã·ã§ã³ãèµ·åããããã³ã«ãµãŒããŒã§èŠæ±ãããæåã®ãã©ã°ã¡ã³ãïŒé£çµ¡å ãªã¹ãïŒãåããããã«ããŒã«ã«ããŒã¿ããŒã¹ã«ä¿åãããŸãã ã¢ããããŒããããåçã®ãªã¹ãã«ã¯ããµãŒããŒã«ã¢ããããŒããããåçã®ã¡ã¿ããŒã¿ãå«ãŸããŠããŸãã ã¢ããªã±ãŒã·ã§ã³ãåã€ã³ã¹ããŒã«ããå Žåãäž¡æ¹ã®ãªã¹ãã¯ãµãŒããŒãšåæãããŸãã
ã³ãŒã6. SQLiteã§ã®äœæ¥ã®äŸ
FriendsDataSourceã¯ã©ã¹
public class FriendsDataSource { private SQLiteDatabase database; private SQLiteHelper dbHelper; private String[] allColumns = { SQLiteHelper.COLUMN_ID,SQLiteHelper.COLUMN_NAME, SQLiteHelper.COLUMN_CONTACT_KEY, SQLiteHelper.COLUMN_USER_ID, SQLiteHelper.COLUMN_AVATAR, SQLiteHelper.COLUMN_STATUS}; ... public FriendEntry createFriend(String Name, String ContactKey, String UserId, String Avatar, int Status) { //Add new FriendEntry ContentValues cv = new ContentValues(); cv.put(dbHelper.COLUMN_CONTACT_KEY,ContactKey); cv.put(dbHelper.COLUMN_NAME,Name); cv.put(dbHelper.COLUMN_USER_ID,UserId); cv.put(dbHelper.COLUMN_AVATAR,Avatar); cv.put(dbHelper.COLUMN_STATUS,Status); cv.put(dbHelper.COLUMN_TYPE,FriendEntry.INT_TYPE_PERSON); database.insert(dbHelper.TABLE_FRIENDS, null, cv); return null; } public ArrayList<FriendEntry> getFriendsByStatus(int StatusSet[]) { String selection = dbHelper.COLUMN_STATUS + " IN (?"; String values[] = new String[StatusSet.length]; values[0] = String.valueOf(StatusSet[0]); for (int i = 1; i < StatusSet.length; i++) { selection = selection + ",?"; values[i] = String.valueOf(StatusSet[i]); } selection = selection + ") "; selection = selection + " AND " + SQLiteHelper.COLUMN_TYPE + " = " + FriendEntry.INT_TYPE_PERSON; String orderBy = SQLiteHelper.COLUMN_NAME + " ASC"; Cursor cursor = database.query(dbHelper.TABLE_FRIENDS, null, selection, values, null, null, orderBy); ArrayList<FriendEntry> listFriends = new ArrayList<FriendEntry>(); if (cursor == null) { return listFriends; } else if (!cursor.moveToFirst()) { cursor.close(); return listFriends; } do{ listFriends.add(cursorToFriendEntry(cursor)); }while (cursor.moveToNext()); cursor.close(); return listFriends; } private FriendEntry cursorToFriendEntry(Cursor cursor) { FriendEntry friend = new FriendEntry(); friend.setId(cursor.getInt(idColIndex)); friend.setName(cursor.getString(nameColIndex)); friend.setUserId(cursor.getString(userIdColIndex)); friend.setAvatar(cursor.getString(avatarColIndex)); friend.setStatus(cursor.getInt(statusColIndex)); friend.setType(cursor.getInt(typeColIndex)); friend.setContactKey(cursor.getString(ContactKeyColIndex)); return friend; } ... }
ç¶ã
èšäºã®ãã®éšåã§ã¯ãAndroidã¯ã©ã€ã¢ã³ãã®éçºæã«çºçããäž»ãªåé¡ãšåé¡ã®ã¿ãæ€èšããããšããŸããã ãã®ãããžã§ã¯ãã¯é±æ«ã®ããã«ãœã³ã®ã¹ã¿ã€ã«ã§éçºãããåæ¥çãªç®æšã¯ãããŸããããã®ãããç¬èªã®ã¢ãããŒããè£ ãããšã¯ãããŸãããå šäœçãªã³ãŒãã¹ã¿ã€ã«ãèªæ ¢ããããšã¯ã§ããŸããã ã¢ãã€ã«ãœãŒã·ã£ã«ã¢ããªã±ãŒã·ã§ã³ãéçºããããã®ä»ã®ãã³ãããœãªã¥ãŒã·ã§ã³ããŸãã¯ã¢ã€ãã¢ãããã°ãã³ã¡ã³ãã§ãèãããã ããã ãŸãããã®ããã¥ã¢ã«ãæ°ã«å ¥ã£ãå ŽåããŸãã¯äŸ¿å©ãªå Žåã¯ããããžã§ã¯ãã§èªç±ã«äœ¿çšãããããã«ãªã¯ãšã¹ããæ¹åãããéä¿¡ãããã§ããŸãã
2çªç®ã®éšåã§ã¯ããµãŒãã¹ã®ãµãŒããŒéšåãAWS S3ã¯ã©ãŠãã¹ãã¬ãŒãžãžã®ç»åã®ã¢ããããŒããç»åã®åŸåŠçãããã·ã¥éç¥ã®é ä¿¡ãªã©ã®æ©èœã«ã€ããŠè©³ããæ€èšããŸãã
è¯ãé±æ«ããéããã«ãªããŸãããã
ç¶ã-ããŒãIIïŒãµãŒããŒïŒ