开发者

What is a recommended Android utility class collection?

I often find myself writing very similar code across projects. And more often than not, I copy stuff over from old projects.

Things like:

  • Create images with round corners
  • read density into a static variable & re-use. 4 lines..
  • disable / hide multiple views / remote views at once. Example:

}

public static void disableViews(RemoteViews views, int... ids) {
    for (int id : ids) {
        views.setInt(id, SET_VISIBILITY, View.GONE);
    }
}

public static void showViews(RemoteViews views, int... ids) {
    for (int id : ids) {
        views.setInt(id, SET_VISIBILITY, View.VISIBLE开发者_开发问答);
    }
}

I'd love to package these kind of functions into 1 letter / 2 letter class names, i.e. V.showViews(RemoteViews views, int... ids) would be easy to write & remember I hope.

I'm searching for Github recommendations, links and if nothing is found, I perhaps will start a small project on github to collect.


You could take a look at https://github.com/kaeppler/droid-fu, it might be worth to study and eventually extend it. It's a utility framework not only for views but covering other aspects as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜