use of org.eclipse.egit.github.core.TreeEntry in project Bitocle by mthli.
the class ContentItemAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
Holder holder;
View view = convertView;
if (view == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
view = inflater.inflate(layoutResId, viewGroup, false);
holder = new Holder();
holder.icon = (ImageView) view.findViewById(R.id.content_item_icon);
holder.title = (TextView) view.findViewById(R.id.content_item_title);
holder.info = (TextView) view.findViewById(R.id.content_item_info);
view.setTag(holder);
} else {
holder = (Holder) view.getTag();
}
ContentItem item = list.get(position);
TreeEntry entry = item.getEntry();
if (entry.getType().equals("tree")) {
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_type_folder));
holder.info.setText("#");
} else {
holder.icon.setImageDrawable(context.getResources().getDrawable(R.drawable.ic_type_file));
if (item.getEntry().getSize() < 1024) {
holder.info.setText(item.getEntry().getSize() + " " + "B");
} else {
double r = round(item.getEntry().getSize() / 1024);
String size = r + " " + "KB";
holder.info.setText(size);
}
}
holder.title.setText(getName(item.getEntry().getPath()));
return view;
}
use of org.eclipse.egit.github.core.TreeEntry in project Bitocle by mthli.
the class StarContentTask method onPostExecute.
@Override
protected void onPostExecute(Boolean result) {
if (result) {
if (flag == Flag.STAR_CONTENT_FIRST || flag == Flag.STAR_CONTENT_REFRESH) {
fragment.setRoot(root);
}
List<TreeEntry> entries = root.getTree();
if (flag == Flag.STAR_CONTENT_FIRST || flag == Flag.STAR_CONTENT_REFRESH) {
list.clear();
for (TreeEntry e : entries) {
String[] a = e.getPath().split("/");
if (a.length == 1) {
list.add(new ContentItem(e));
}
}
Collections.sort(list);
if (list.size() <= 0) {
bookmark.setVisible(false);
fragment.setContentEmpty(true);
fragment.setEmptyText(R.string.content_empty_list);
fragment.setContentShown(true);
} else {
bookmark.setVisible(true);
fragment.setContentEmpty(false);
adapter.notifyDataSetChanged();
fragment.setContentShown(true);
}
} else {
list.clear();
String[] a = entry.getPath().split("/");
for (TreeEntry e : entries) {
String[] r = e.getPath().split("/");
if ((r.length - 1 == a.length) && e.getPath().startsWith(entry.getPath())) {
list.add(new ContentItem(e));
}
}
Collections.sort(list);
if (list.size() <= 0) {
bookmark.setVisible(false);
fragment.setContentEmpty(true);
fragment.setEmptyText(R.string.content_empty_list);
fragment.setContentShown(true);
} else {
bookmark.setVisible(true);
fragment.setContentEmpty(false);
adapter.notifyDataSetChanged();
fragment.setContentShown(true);
}
}
} else {
bookmark.setVisible(false);
fragment.setContentEmpty(true);
fragment.setEmptyText(R.string.content_empty_error);
fragment.setContentShown(true);
}
}
Aggregations