Android Open Source - LearningAndroid2edYamba2 Details Fragment






From Project

Back to project page LearningAndroid2edYamba2.

License

The source code is released under:

Apache License

If you think the Android project LearningAndroid2edYamba2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.marakana.android.yamba;
//w  w  w  . j a v a2  s  .  c o m
import android.app.Fragment;
import android.content.ContentUris;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class DetailsFragment extends Fragment {
  private TextView textUser, textMessage, textCreatedAt;

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.list_item, null, false);

    textUser = (TextView) view.findViewById(R.id.list_item_text_user);
    textMessage = (TextView) view.findViewById(R.id.list_item_text_message);
    textCreatedAt = (TextView) view
        .findViewById(R.id.list_item_text_created_at);

    return view;
  }

  @Override
  public void onResume() {
    super.onResume();
    long id = getActivity().getIntent().getLongExtra(
        StatusContract.Column.ID, -1);

    updateView(id);
  }
  
  public void updateView(long id) {
    if (id == -1) {
      textUser.setText("");
      textMessage.setText("");
      textCreatedAt.setText("");
      return;
    }

    Uri uri = ContentUris.withAppendedId(StatusContract.CONTENT_URI, id);
    
    Cursor cursor = getActivity().getContentResolver().query(uri, null,
        null, null, null);
    if (!cursor.moveToFirst())
      return;
    
    String user = cursor.getString(cursor
        .getColumnIndex(StatusContract.Column.USER));
    String message = cursor.getString(cursor
        .getColumnIndex(StatusContract.Column.MESSAGE));
    long createdAt = cursor.getLong(cursor
        .getColumnIndex(StatusContract.Column.CREATED_AT));
    
    textUser.setText(user);
    textMessage.setText(message);
    textCreatedAt.setText(DateUtils.getRelativeTimeSpanString(createdAt));    
  }
}




Java Source Code List

com.marakana.android.yamba.BootReceiver.java
com.marakana.android.yamba.DbHelper.java
com.marakana.android.yamba.DetailsActivity.java
com.marakana.android.yamba.DetailsFragment.java
com.marakana.android.yamba.FreshnessView.java
com.marakana.android.yamba.MainActivity.java
com.marakana.android.yamba.NotificationReceiver.java
com.marakana.android.yamba.RefreshService.java
com.marakana.android.yamba.SettingsActivity.java
com.marakana.android.yamba.SettingsFragment.java
com.marakana.android.yamba.StatusActivity.java
com.marakana.android.yamba.StatusContract.java
com.marakana.android.yamba.StatusFragment.java
com.marakana.android.yamba.StatusProvider.java
com.marakana.android.yamba.SubActivity.java
com.marakana.android.yamba.TimelineFragment.java
com.marakana.android.yamba.YambaWidget.java