Search in sources :

Example 6 with UrlSuggestion

use of com.odysee.app.model.UrlSuggestion in project odysee-android by OdyseeTeam.

the class UrlSuggestionListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(UrlSuggestionListAdapter.ViewHolder vh, int position) {
    UrlSuggestion item = items.get(position);
    String fullTitle, desc;
    int iconStringId;
    switch(item.getType()) {
        case UrlSuggestion.TYPE_CHANNEL:
            iconStringId = R.string.fa_at;
            fullTitle = item.getTitle();
            desc = item.getClaim() != null ? item.getClaim().getTitle() : ((item.isUseTextAsDescription() && !Helper.isNullOrEmpty(item.getText())) ? item.getText() : String.format(context.getString(R.string.view_channel_url_desc), item.getText()));
            break;
        case UrlSuggestion.TYPE_TAG:
            iconStringId = R.string.fa_hashtag;
            fullTitle = String.format(context.getString(R.string.tag_url_title), item.getText());
            desc = String.format(context.getString(R.string.explore_tag_url_desc), item.getText());
            break;
        case UrlSuggestion.TYPE_SEARCH:
            iconStringId = R.string.fa_search;
            fullTitle = String.format(context.getString(R.string.search_url_title), item.getText());
            desc = String.format(context.getString(R.string.search_url_desc), item.getText());
            break;
        case UrlSuggestion.TYPE_FILE:
        default:
            iconStringId = R.string.fa_file;
            fullTitle = item.getTitle();
            desc = item.getClaim() != null ? item.getClaim().getTitle() : ((item.isUseTextAsDescription() && !Helper.isNullOrEmpty(item.getText())) ? item.getText() : String.format(context.getString(R.string.view_file_url_desc), item.getText()));
            break;
    }
    vh.iconView.setText(iconStringId);
    vh.titleView.setText(fullTitle);
    vh.descView.setText(desc);
    vh.itemView.setOnClickListener(view -> {
        if (listener != null) {
            listener.onUrlSuggestionClicked(item);
        }
    });
}
Also used : UrlSuggestion(com.odysee.app.model.UrlSuggestion)

Example 7 with UrlSuggestion

use of com.odysee.app.model.UrlSuggestion in project odysee-android by OdyseeTeam.

the class Helper method saveUrlHistory.

public static void saveUrlHistory(String url, String title, int type) {
    DatabaseHelper dbHelper = DatabaseHelper.getInstance();
    if (dbHelper != null) {
        UrlSuggestion suggestion = new UrlSuggestion();
        suggestion.setUri(LbryUri.tryParse(url));
        suggestion.setType(type);
        suggestion.setText(Helper.isNull(title) ? "" : title);
        new SaveUrlHistoryTask(suggestion, dbHelper, null).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
}
Also used : DatabaseHelper(com.odysee.app.data.DatabaseHelper) SaveUrlHistoryTask(com.odysee.app.tasks.localdata.SaveUrlHistoryTask) UrlSuggestion(com.odysee.app.model.UrlSuggestion)

Aggregations

UrlSuggestion (com.odysee.app.model.UrlSuggestion)7 ArrayList (java.util.ArrayList)5 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 DatabaseHelper (com.odysee.app.data.DatabaseHelper)1 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)1 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)1 LbryUriException (com.odysee.app.exceptions.LbryUriException)1 FetchRecentUrlHistoryTask (com.odysee.app.tasks.localdata.FetchRecentUrlHistoryTask)1 SaveUrlHistoryTask (com.odysee.app.tasks.localdata.SaveUrlHistoryTask)1 LbryUri (com.odysee.app.utils.LbryUri)1 IOException (java.io.IOException)1 List (java.util.List)1 OkHttpClient (okhttp3.OkHttpClient)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1 ResponseBody (okhttp3.ResponseBody)1 JSONArray (org.json.JSONArray)1 JSONException (org.json.JSONException)1