Search in sources :

Example 6 with GistFile

use of com.meisolsson.githubsdk.model.GistFile in project gh4a by slapperwan.

the class GistActivity method fillData.

private void fillData(final Gist gist) {
    mGist = gist;
    if (gist.owner() != null) {
        getSupportActionBar().setSubtitle(gist.owner().login());
    }
    TextView tvDesc = findViewById(R.id.tv_desc);
    tvDesc.setText(TextUtils.isEmpty(gist.description()) ? getString(R.string.gist_no_description) : gist.description());
    TextView tvCreatedAt = findViewById(R.id.tv_created_at);
    tvCreatedAt.setText(StringUtils.formatRelativeTime(this, gist.createdAt(), true));
    Map<String, GistFile> files = gist.files();
    if (files != null && !files.isEmpty()) {
        ViewGroup container = findViewById(R.id.file_container);
        LayoutInflater inflater = getLayoutInflater();
        container.removeAllViews();
        for (GistFile gistFile : files.values()) {
            TextView rowView = (TextView) inflater.inflate(R.layout.selectable_label, container, false);
            rowView.setText(gistFile.filename());
            rowView.setTextColor(UiUtils.resolveColor(this, android.R.attr.textColorPrimary));
            rowView.setOnClickListener(this);
            rowView.setTag(gistFile);
            container.addView(rowView);
        }
    } else {
        findViewById(R.id.file_card).setVisibility(View.GONE);
    }
    findViewById(R.id.tv_private).setVisibility(gist.isPublic() ? View.GONE : View.VISIBLE);
}
Also used : ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) GistFile(com.meisolsson.githubsdk.model.GistFile)

Example 7 with GistFile

use of com.meisolsson.githubsdk.model.GistFile in project gh4a by slapperwan.

the class GistActivity method onClick.

@Override
public void onClick(View view) {
    GistFile file = (GistFile) view.getTag();
    startActivity(GistViewerActivity.makeIntent(this, mGistId, file.filename()));
}
Also used : GistFile(com.meisolsson.githubsdk.model.GistFile)

Aggregations

GistFile (com.meisolsson.githubsdk.model.GistFile)7 Context (android.content.Context)2 Bundle (android.os.Bundle)2 LayoutInflater (android.view.LayoutInflater)2 ViewGroup (android.view.ViewGroup)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 SharedPreferences (android.content.SharedPreferences)1 OnSharedPreferenceChangeListener (android.content.SharedPreferences.OnSharedPreferenceChangeListener)1 NonNull (android.support.annotation.NonNull)1 Fragment (android.support.v4.app.Fragment)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 ArrayMap (android.support.v4.util.ArrayMap)1 Menu (android.view.Menu)1 MenuInflater (android.view.MenuInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 WebView (android.webkit.WebView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1