use of io.github.mthli.Bitocle.Content.RepoContentTask in project Bitocle by mthli.
the class MainFragment method clickWhenRepo.
private void clickWhenRepo(int position) {
allTaskDown();
hideWhenContent();
RepoItem item = repoItemList.get(position);
owner = item.getOwner();
name = item.getName();
title = name;
subTitle = name;
actionBar.setTitle(title);
actionBar.setSubtitle(subTitle);
actionBar.setDisplayHomeAsUpEnabled(true);
root = null;
entry = null;
toggle = false;
prefix = "/";
listView.setAdapter(contentItemAdapter);
contentItemAdapter.notifyDataSetChanged();
flag = Flag.REPO_CONTENT_FIRST;
currentId = REPO_CONTENT_ID;
repoContentTask = new RepoContentTask(MainFragment.this);
repoContentTask.execute();
}
use of io.github.mthli.Bitocle.Content.RepoContentTask in project Bitocle by mthli.
the class MainFragment method clickWhenRepoContent.
private void clickWhenRepoContent(int position) {
allTaskDown();
ContentItem item = contentItemList.get(position);
if (item.getEntry().getType().equals("tree")) {
entry = item.getEntry();
String[] arr = entry.getPath().split("/");
title = arr[arr.length - 1];
if (toggle) {
if (prefix.equals("/")) {
subTitle = name + "/" + entry.getPath();
} else {
subTitle = name + "/" + prefix + "/" + entry.getPath();
}
} else {
subTitle = name + "/" + entry.getPath();
}
actionBar.setTitle(title);
actionBar.setSubtitle(subTitle);
actionBar.setDisplayHomeAsUpEnabled(true);
flag = Flag.REPO_CONTENT_SECOND;
currentId = REPO_CONTENT_ID;
repoContentTask = new RepoContentTask(MainFragment.this);
repoContentTask.execute();
} else {
TreeEntry e = item.getEntry();
String[] a = e.getPath().split("/");
String t = a[a.length - 1];
if (MimeType.isUnSupport(t)) {
SuperToast.create(view.getContext(), getString(R.string.webview_unsupport), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.RED)).show();
} else {
String s;
if (toggle) {
if (prefix.equals("/")) {
s = name + "/" + e.getPath();
} else {
s = name + "/" + prefix + "/" + e.getPath();
}
} else {
s = name + "/" + e.getPath();
}
Intent intent = new Intent(getActivity(), WebViewActivity.class);
intent.putExtra(getString(R.string.webview_intent_title), t);
intent.putExtra(getString(R.string.webview_intent_subtitle), s);
intent.putExtra(getString(R.string.webview_intent_owner), owner);
intent.putExtra(getString(R.string.webview_intent_name), name);
intent.putExtra(getString(R.string.webview_intent_sha), item.getEntry().getSha());
startActivityForResult(intent, 0);
}
}
}
use of io.github.mthli.Bitocle.Content.RepoContentTask in project Bitocle by mthli.
the class MainFragment method clickWhenBookmark.
private void clickWhenBookmark(int position) {
allTaskDown();
bookmarkItem = bookmarkItemList.get(position);
owner = bookmarkItem.getOwner();
name = bookmarkItem.getName();
if (bookmarkItem.getType().equals("tree")) {
hideWhenContent();
title = bookmarkItem.getTitle();
subTitle = name + "/" + bookmarkItem.getPath();
actionBar.setTitle(title);
actionBar.setSubtitle(subTitle);
actionBar.setDisplayHomeAsUpEnabled(true);
listView.setAdapter(contentItemAdapter);
contentItemAdapter.notifyDataSetChanged();
root = null;
entry = null;
toggle = true;
prefix = bookmarkItem.getPath();
switch(flag) {
case Flag.REPO_FIRST:
case Flag.REPO_SECOND:
case Flag.REPO_REFRESH:
case Flag.REPO_CONTENT_FIRST:
case Flag.REPO_CONTENT_SECOND:
case Flag.REPO_CONTENT_REFRESH:
flag = Flag.REPO_CONTENT_FIRST;
currentId = REPO_CONTENT_ID;
repoContentTask = new RepoContentTask(MainFragment.this);
repoContentTask.execute();
break;
case Flag.STAR_FIRST:
case Flag.STAR_SECOND:
case Flag.STAR_REFRESH:
case Flag.STAR_CONTENT_FIRST:
case Flag.STAR_CONTENT_SECOND:
case Flag.STAR_CONTENT_REFRESH:
flag = Flag.STAR_CONTENT_FIRST;
currentId = STAR_CONTENT_ID;
starContentTask = new StarContentTask(MainFragment.this);
starContentTask.execute();
break;
default:
break;
}
} else {
if (MimeType.isUnSupport(bookmarkItem.getTitle())) {
SuperToast.create(view.getContext(), getString(R.string.webview_unsupport), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.RED)).show();
} else {
Intent intent = new Intent(getActivity(), WebViewActivity.class);
intent.putExtra(getString(R.string.webview_intent_title), bookmarkItem.getTitle());
String sub = bookmarkItem.getName() + "/" + bookmarkItem.getPath();
intent.putExtra(getString(R.string.webview_intent_subtitle), sub);
intent.putExtra(getString(R.string.webview_intent_owner), bookmarkItem.getOwner());
intent.putExtra(getString(R.string.webview_intent_name), bookmarkItem.getName());
intent.putExtra(getString(R.string.webview_intent_sha), bookmarkItem.getSha());
startActivityForResult(intent, 0);
}
}
}
use of io.github.mthli.Bitocle.Content.RepoContentTask in project Bitocle by mthli.
the class MainFragment method refreshAction.
public void refreshAction() {
switch(currentId) {
case REPO_ID:
if (repoTask != null && repoTask.getStatus() == AsyncTask.Status.FINISHED) {
if (flag == Flag.REPO_FIRST) {
if (isContentEmpty()) {
changeToRepo(Flag.REPO_FIRST);
}
} else {
changeToRepo(Flag.REPO_REFRESH);
}
}
break;
case STAR_ID:
if (starTask != null && starTask.getStatus() == AsyncTask.Status.FINISHED) {
changeToStar(true);
}
break;
case BOOKMARK_ID:
changeToBookmark();
SuperToast.create(view.getContext(), view.getContext().getString(R.string.bookmark_refresh_successful), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.BLUE)).show();
break;
case REPO_CONTENT_ID:
if (repoContentTask != null && repoContentTask.getStatus() == AsyncTask.Status.FINISHED) {
if (entry == null) {
flag = Flag.REPO_CONTENT_REFRESH;
repoContentTask = new RepoContentTask(MainFragment.this);
repoContentTask.execute();
} else {
SuperToast.create(view.getContext(), view.getContext().getString(R.string.content_refresh_successful), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.BLUE)).show();
}
}
break;
case STAR_CONTENT_ID:
if (starContentTask != null && starContentTask.getStatus() == AsyncTask.Status.FINISHED) {
if (entry == null) {
flag = Flag.STAR_CONTENT_REFRESH;
starContentTask = new StarContentTask(MainFragment.this);
starContentTask.execute();
} else {
SuperToast.create(view.getContext(), view.getContext().getString(R.string.content_refresh_successful), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.BLUE)).show();
}
}
break;
case COMMIT_ID:
if (commitTask != null && commitTask.getStatus() == AsyncTask.Status.FINISHED) {
switch(flag) {
case Flag.REPO_COMMIT_FIRST:
case Flag.REPO_COMMIT_REFRESH:
changeToCommit(Flag.REPO_COMMIT_REFRESH);
break;
case Flag.STAR_COMMIT_FIRST:
case Flag.STAR_COMMIT_REFRESH:
changeToCommit(Flag.STAR_COMMIT_REFRESH);
break;
default:
break;
}
}
break;
default:
break;
}
}
use of io.github.mthli.Bitocle.Content.RepoContentTask in project Bitocle by mthli.
the class MainFragment method clickWhenSearchItem.
private void clickWhenSearchItem(View view) {
allTaskDown();
hideWhenContent();
TextView ownerText = (TextView) view.findViewById(R.id.auto_item_owner);
TextView nameText = (TextView) view.findViewById(R.id.auto_item_name);
owner = ownerText.getText().toString();
name = nameText.getText().toString();
title = name;
subTitle = name;
actionBar.setTitle(title);
actionBar.setSubtitle(subTitle);
actionBar.setDisplayHomeAsUpEnabled(true);
root = null;
entry = null;
toggle = false;
prefix = "/";
listView.setAdapter(contentItemAdapter);
contentItemAdapter.notifyDataSetChanged();
flag = Flag.REPO_CONTENT_FIRST;
currentId = REPO_CONTENT_ID;
repoContentTask = new RepoContentTask(MainFragment.this);
repoContentTask.execute();
}
Aggregations